1

In my .htaccess file whenever I create 301 redirects, the url to be redirected from is appended to the url to be redirected to. For example:

Redirect /linksresources.html http://example.com/resources/ 

Will redirect me to:

http://example.com/resources/?/linksresources.html 

The existing .htaccess file:

#404 Custom Error page #ErrorDocument 404 /error_docs/404.php #force IE out of compatibility mode <FilesMatch "\.(htm|html|php)$"> <IfModule mod_headers.c> BrowserMatch MSIE ie Header set X-UA-Compatible "IE=Edge,chrome=1" </IfModule> </FilesMatch> #Disable Indexing Options -Indexes Order Deny,Allow Allow from All Redirect /linksresources.html http://example.com/resources/ RewriteEngine On RewriteOptions inherit #if request is not an existing file or directory then redirect to #codeigniter boot.php file RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ boot.php?/$1 [L,QSA] 

I feel like I have resolved this issue in the past, but I can not remember what it was that I did. Does anyone have any suggestions?

1 Answer 1

1

This is the result of a conflict with your mod_rewrite directives, which are executing before the mod_alias Redirect directive, despite the apparent order in your config file. Different modules execute at different times during the request. For this reason, it is not recommended to mix redirects from both modules.

Specifically, the existing RewriteRule is being triggered since presumably /linksresource.html does not exist as a physical file and is being internally rewritten to boot.php?/linksresource.html. The mod_alias Redirect then fires, matching /linksresource.html against the original request and redirects to http://example.com/resources/?/linksresources.html - passing the query string through from the rewritten request.

Since you are already using mod_rewrite, you should change the mod_alias Redirect to the equivalent mod_rewrite RewriteRule:

RewriteRule ^linksresources\.html$ http://example.com/resources/ [R=302,L] 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.