Welcome Guest, Not a member yet? Register   Sign In
htaccess 301 redirect help please
#11

[eluser]Daniel Moore[/eluser]
Quote:and you will note http://lakesideohio.com/LakesideExperien...tions.aspx still results in the URL http://lakesideohio.com/directions?/Lake...tions.aspx

I would recommend using the rewrite, then.

You say you have a lot of these redirects to do? Putting all that in the .htaccess one at a time will slow you down quite a bit. That really would not be a good route to go.

There are several methods you can use to get around this. Sometimes you just need to simplify your problem/solution a bit.

If you are simply needing to redirect ALL .aspx files, then perhaps you can use a regex expression in your .htaccess code to do it in just one line. It may not follow a simple enough pattern for a regex expression there, so I would recommend the alternative method listed in the next paragraph.

Alternatively, and this is my recommended option, you might consider "rewriting" the .aspx files and replace them with the Response.Redirect() to redirect these files to the new location. It might be more time consuming to edit each file, but will give you better server performance over the long run, and as such should be considered. The obvious reason for the increased performance would be that the server won't have to read additional lines concerning the redirects unless that file is actually accessed. If in the .htaccess, then it will have to be considered on every site access, whether needed or not. You might consider using a utility to compile a list of all the files that need changing, place them in a text file, and use a macro/script to create your redirect files automatically if you consider this option.
#12

[eluser]michaeljdennis[/eluser]
I have a similar problem. I got a site converted to codeigniter. I am trying to redirect the old URL's. 301 redirects work in the htaccess but it adds a ?/product-category/ to the end of the url for some reason.
#13

[eluser]TheFuzzy0ne[/eluser]
Please post your htaccess file.
#14

[eluser]michaeljdennis[/eluser]
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

RewriteCond $1 !^(index\.php|css|drawings|images|js)
RewriteRule ^(.*)$ /index.php?/$1 [L]

redirect 301 /shoes http://www.example.com/products/all/shoes



Using this htaccess file, I go to example.com/shoes and it redirects me to example.com/products/all/shoes/?/shoes/
#15

[eluser]Chad Fulton[/eluser]
The problem with both of these .htaccess files is the fact that they're trying to use both Redirect (mod_alias) and Rewrite (mod_rewrite).

Essentially what happens is this:

1. Rewrites are called before redirects (regardless of where they are placed in the .htaccess file), so the rewrite engine takes a look at, e.g., the URI /transaction-windows.
2. It applies the usual rules to it (which makes it the query string after index.php), so you get something like http://www.bulletproofspecs.com/index.ph...n-windows/
3. Now the redirect is called based upon the original URI (/transaction-windows) but we keep the query string generated from the mod_rewrite! So, the redirect takes us to http://www.bulletproofspecs.com/products...n-windows/
4. Then we go through mod_rewrite a second time, based on the URI from step 3, and get the appropriate internal URL http://www.bulletproofspecs.com/index.ph...on-windows

The key to correcting this behavior is to do it all using mod_rewrite, and not to mix it with mod_alias.
#16

[eluser]Unknown[/eluser]
I know this is an old thread but it came top when I was searching for a solution to the above problem. The way I got this working was to add the folder to the allowed folders list e.g.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|oldfolder|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php?/$1 [L]

redirect 301 /oldfolder http://www.mywebsite.co.uk/pages/newfolder




Theme © iAndrew 2016 - Forum software by © MyBB