Forum Moderators: phranque

Message Too Old, No Replies

rewriting, an already written rewrite rule

as moving to a new folder

         

nippi

2:12 am on Nov 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a folder, with a htaccess rewrite rule for the contents of that folder, but now i need to move everything to another folder.

eg

folder a htaccess

RewriteEngine on
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_URI} !//
RewriteRule (.*)/(.*)/(.*)/(.*) $1.php?id=$3&page=$4&name=$2 [L]

this works fine for the files in folder a, but I need a rule like this

RewriteEngine on
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_URI} !//
RewriteRule (folder a)(.*)/(.*)/(.*)/(.*) $1.php?id=$3&page=$4&name=$2 [L]

for the OLD folder

can not get the syntax right.

anyone?

g1smd

3:04 am on Nov 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Multiple .* patterns are horribly inefficient.

See the comments in [webmasterworld.com...] from just a few hours ago.

When you say you want to "move folder"...
Do you want to move the files around on the server but keep the same URLs, or
Do you want to keep the files in the same place on the server but change the URLs?

That isn't clear from your question.

Mod_rewrite cannot change URLs - URLs are defined by the links on your pages.

If you are moving to new URLs you should also set up a redirect so that requests for the old URLs are redirected to the new URLs.

It is a very bad idea to change all the URLs. In this case it looks like a rewrite could be used such that you keep the same old URLs and the rewrite connects that URL request to the new internal location of the files within the server without revealing what that location actually is.

nippi

10:14 pm on Nov 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



everything needs to go up a folder

eg

species/frogs/cuban-hopping-frog/45/1

to

animals/species/frogs/cuban-hopping-frog/45/1

jdMorgan

11:02 pm on Nov 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



URLs and filepaths are not the same thing: You can change one without changing the other. That is why g1smd asked his question above. Given a choice, you should limit URL changes to one change per URL every twenty years or so.

We need to know what will change in the URL from the old URL to the new URL, and what will change in the filesystem from old filepath to new filepath, so please make this clear.

Otherwise, you may get an exquisitely-detailed, beautifully-elegant, and perfect solution to the wrong question...

Jim

g1smd

1:19 am on Nov 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is there an answer to the question yet?