.htaccess error on wallpaper website - apache

I installed wallpaper script but it's giving this error on main page:
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
I think this is .htaccess file. I am pasting the .htaccess file below:
#php_flag display_errors On
#Options +FollowSymlinks
RewriteEngine Off
RewriteEngine On
#change / with the relative path if you install the script in a subdirectory
#RewriteBase /wallpaperscript.com/script/
#This is for redirecting links with any subdomain to no subdomain
#RewriteCond %{HTTP_HOST} ^(.+).wallpapers.net [NC]
#RewriteRule ^(.*)$ http://wallpapers.net/$1 [R=301,NC,L]
#This is for redirecting links without trailing / to links with trailing /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_URI} !(.*)\.(.+){3,4}
#RewriteCond %{REQUEST_URI} !(.*)/$
#RewriteRule ^(.*)$ /$1/ [L,R=301]
#RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)-desktop-wallpapers([^/]*)(/){0,1}([^/]*)$ $4-desktop-wallpapers$5$6$7
#RewriteRule ^([^/]*)/([^/]*)/([^/]*)-desktop-wallpapers([^/]*)(/){0,1}([^/]*)$ $3-desktop-wallpapers$4$5$6
#RewriteRule ^([^/]*)/([^/]*)-desktop-wallpapers([^/]*)(/){0,1}([^/]*)$ $2-desktop-wallpapers$3$4$5
#RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)-wallpapers([^/]*)(/){0,1}([^/]*)$ $4-wallpapers$5$6$7
#RewriteRule ^([^/]*)/([^/]*)/([^/]*)-wallpapers([^/]*)(/){0,1}([^/]*)$ $3-wallpapers$4$5$6
#RewriteRule ^([^/]*)/([^/]*)-wallpapers([^/]*)(/){0,1}([^/]*)$ $2-wallpapers$3$4$5
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?%{QUERY_STRING}&resource=$1 [L]
Is there any problem with this? My site's URL is www.hotwallpapers.pk

Try to put: "RewriteBase /" under "RewriteEngine On" so it looks like this:
php_flag display_errors On
Options +FollowSymlinks
RewriteEngine Off
RewriteEngine On
RewriteBase /
change / with the relative path if you install the script in a subdirectory
RewriteBase /wallpaperscript.com/script/
This is for redirecting links with any subdomain to no subdomain
RewriteCond %{HTTP_HOST} ^(.+).wallpapers.net [NC]
RewriteRule ^(.*)$ http://wallpapers.net/$1 [R=301,NC,L]
This is for redirecting links without trailing / to links with trailing /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*).(.+){3,4}
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /$1/ [L,R=301]
RewriteRule ^([^/])/([^/])/([^/])/([^/])-desktop-wallpapers([^/])(/){0,1}([^/])$ $4-desktop-wallpapers$5$6$7
RewriteRule ^([^/])/([^/])/([^/])-desktop-wallpapers([^/])(/){0,1}([^/]*)$ $3-desktop-wallpapers$4$5$6
RewriteRule ^([^/])/([^/])-desktop-wallpapers([^/])(/){0,1}([^/])$ $2-desktop-wallpapers$3$4$5
RewriteRule ^([^/])/([^/])/([^/])/([^/])-wallpapers([^/])(/){0,1}([^/])$ $4-wallpapers$5$6$7
RewriteRule ^([^/])/([^/])/([^/])-wallpapers([^/])(/){0,1}([^/]*)$ $3-wallpapers$4$5$6
RewriteRule ^([^/])/([^/])-wallpapers([^/])(/){0,1}([^/])$ $2-wallpapers$3$4$5
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?%{QUERY_STRING}&resource=$1 [L]

Related

Apache Redirect certain HTTPS requests to HTTP not working

Hi I have been working on this for a while and just know I am doing something stupid but just can not see it. What I want to do is to redirect certain pages so they are always shown using HTTPS and all other pages if they are requested through HTTPS they are redirected as HTTP.
I have done lots of searching around the issue and found accepted answers on Stackoverflow that just did not work for me. So here Is my .htaccess file.
RewriteCond %{HTTPS} on
RewriteCond ${REQUEST_URI} !(finance/enquiryForm)(.*)
RewriteCond ${REQUEST_URI} !(offerentry)(.*)
RewriteRule (.*) http://dev.staging.co.uk/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(finance/enquiryForm|offerentry)(.*) https://dev.staging.co.uk/$1 [L,R=301]
What is currently happening is that the pages that I want to redirect from https to http work fine but the pages I want to show as HTTPS get a redirect loop and fail. If I comment out the top section the HTTPS pages I do want redirect fine. So how do I get the redirect loop to stop?
EDIT
The full .htaccess file with the codeigniter etc stuff.
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
<Files .*>
Order Deny,Allow
Deny From All
</Files>
#RewriteCond %{HTTPS} on
#RewriteCond ${REQUEST_URI} !/(finance/enquiryForm|offerentry) [NC]
#RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE]
#RewriteCond %{HTTPS} off
#RewriteCond ${REQUEST_URI} /(finance/enquiryForm|offerentry) [NC]
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE]
# Protect application and system files from being viewed
RewriteRule ^(fuel/install/.+|fuel/crons/.+|fuel/data_backup/.+|fuel/codeigniter/.+|fuel/modules/.+|fuel/application/.+|\.$
# Remove trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)/$
RewriteCond %{REQUEST_URI} !fuel/.*$
RewriteRule ^(.*)/$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [L]
</IfModule>
Options -Indexes
Try these rules based on THE_REQUEST variable:
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} !/(finance/enquiryForm|offerentry) [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE]
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} /(finance/enquiryForm|offerentry) [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE]
Test them in Chrome dev tool and see what redirects are you getting.
Try with:
RewriteCond %{HTTPS} on
RewriteCond ${REQUEST_URI} !(finance/enquiryForm|offerentry)
RewriteRule (.*) http://dev.staging.co.uk/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule (finance/enquiryForm|offerentry) https://dev.staging.co.uk%{REQUEST_URI} [NE,L,R=301]

htacess Proxy Redirect /a to /b, 301 redirect of /b to /a

I have website built on a bespoke centralised legacy CMS.
It has a section which works under the URL /database
For one site I'd like to change that to use /blog and it still needs to tell the CMS that it's database.
So for .htaccess I have
RewriteRule ^blog$ /database [P,L]
RewriteRule ^blog/(.*)$ /database/$1 [P,L]
Which works great. But I also need to tell google that the site has changed and not to look at the old one.
So I need /database to 301 to /blog.
So:
RewriteRule ^database$ /blog [L,R=301]
I've tested this with http://htaccess.madewithlove.be and it says it's fine, but it's causing an infinite loop in the browser.
To be honest I feel like part of the problem is that I can't really express the question very well, especially the title, so any feedback on that would be appreciated.
Here's the rest of the file just in case that's relevant
# redirect trailing slashes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.+)?fromMobile=true$ [NC]
RewriteRule (.*) /$1?%1&%2 [R=301,L]
RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L]
#uk.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^iflg\.uk\.com$ [NC]
RewriteRule ^(.*)$ http://www.iflg.uk.com/$1 [R=301,L]
RewriteRule ^blog$ /database [P,L]
RewriteRule ^blog/(.*)$ /database/$1 [P,L]
#RewriteCond %{REMOTE_ADDR} !=localhost
#RewriteRule ^database$ /blog [L,R=301]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~iflg/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~iflg/index.php
</IfModule>
You need to exempt the second rule to prevent the proxy server from being redirected too.
RewriteCond %{REMOTE_ADDR} !=127.0.0.1
RewriteRule ^database$ /blog [L,R=301]
Do not rely on that htaccess tester, it is too simplistic.

Apache htaccess - route all requests to index.php except those to certain directories

Currently, my .htaccess file is routing all requests where the file does not exist to index.php. I would like to alter this so that it routes all requests to index.php regardless of whether or not the file exists, except for certain directories/paths. (such as /js, /css, /img)
Here is my current configuration:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I'm having trouble figuring out how to do this with the Google or apache's documentation. Help is much appreciated, as are any general tips on this issue.
The following should work
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} ! ^/css/ [OR]
RewriteCond %{REQUEST_FILENAME} ! ^/img/ [OR]
RewriteCond %{REQUEST_FILENAME} ! ^/js/
RewriteRule . /index.php [L]
</IfModule>

.htaccess ensure www redirect incorrect

I am trying to ensure that urls always have www in front of them for canonicalization reasons.
Unfortunately when I put the following url in:
http://website.net/handbags/1/12/this-is-some-text
It redirects me here:
http://www.website.net/?controller=handbags&path=1/12/this-is-some-text
I would like to add it works fine when using:
http://www.website.net/handbags/1/12/this-is-some-text
I want it to redirect me here...
http://www.website.net/handbags/1/12/this-is-some-text
I'm not sure what could be causing this error. Here is my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# CORE REDIRECT
RewriteRule ^([a-zA-Z]*)/?(.*)?$ index.php?controller=$1&path=$2 [NC,L]
# ENSURE WWW
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+\.[a-z]{2,6})$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# ENSURE WWW
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+\.[a-z]{7})$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# CORE REDIRECT
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z]*)/?(.*)?$ index.php?controller=$1&path=$2 [NC,L]
</IfModule>
You can do what I've done above; however, it's just going to redirect to http://www.website.net/handbags/1/12/this-is-some-text and then it's immediately going to hit the "CORE REDIRECT" rule and send you to http://www.website.net/?controller=handbags&path=1/12/this-is-some-text.
Is there a reason you don't want it to redirect to "?controller=handbags" when they go to www?
UPDATE
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# ENSURE WWW
Rewritecond %{HTTP_HOST} !^www\.website\.net
RewriteRule ^(.*)$ http://www.website.net/$1 [R=301,L]
# CORE REDIRECT
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z]*)/?(.*)?$ index.php?controller=$1&path=$2 [NC,L]
</IfModule>
Whenever your # CORE REDIRECT matches, the other rules are not even checked, as the core redirect rule has the Lflag set. That ones tells Apache to stop trying other rules. Remove that flag or change the rule. ;)

htaccess rewrite url redirect php file to folder

I want to redirect this php url to the folder.
I always used the settings below. But since the update of apache to 2.4 it doesnt work anymore.
Goal:
example.com/about.php?sub=about or example.com/about.php?sub= should be seen in the browser as example.com/about/
I use the following settings.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(example.com)(:80)? [NC]
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]
RewriteRule ^about/$ about.php$1 [L]
RewriteRule ^about/([A-Za-z0-9-]+)$ about.php?sub=$1 [L]
This is what I am using now...
I don't see any rule in your code that is making /about.php?sub= to /about.
Try this code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(about)\.php(\?sub=[^\s&]*)?\s [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteRule ^about/?$ about.php?sub=about [L,NC,QSA]
RewriteRule ^about/([a-z0-9-]+)/?$ about.php?sub=$1 [L,NC,QSA]
# Add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R]