views:

17

answers:

0

I have the following problem. We used many different URLs to the same page. Now we want to use only one URL for those pages. Here an example:

RewriteRule ^(subfolder1/folder1/|(subfolder2|subfolder3)/folder2/|folder3/)?(name1|name2|name3|name4)$ scriptname.php [QSA,NC]

As you can see it is pretty messy. What I now want to do is the following: Rewrite all URLs to only one of those URLs (e.g. subfolder1/folder1/name1) using a 301 and than using a rewrite on that URL to address the actual script. It might look like this:

RewriteRule ^((subfolder2|subfolder3)/folder2/|folder3/)?(name2|name3|name4)$ /subfolder1/folder1/name1 [R=301,QSA,NC]
RewriteRule ^subfolder1/folder1/name1$ script.php [QSA.NC]

Until here I have no problem. But now comes the tricky part. We use several development machines on UNIX and Windows machines. They all have different host names and folder. Here are some examples:

http://www.example.com (production)
http://test.example.com (testing)
http://localhost/development_folder/ (development WIN)
http://localhost:8888/development_folder/ (development MAC)

The issue is, that as we have subfolders on the development machines, I can't use an absolute URL as /subfolder1/folder1/name1/ as it would e.g. point to http://localhost/subfolder1/folder1/name1/ and not to http://localhost/development_folder/subfolder1/folder1/name1/ so all the rewrites would be broken on the development machines.

Is there any chance to get this issue working? As the folder development_folderis the same on all development machines, would it help to exclude/include that folder to the rewrites afterwards like this:

RewriteRule ^((subfolder2|subfolder3)/folder2/|folder3/)?(name2|name3|name4)$ /development_folder/subfolder1/folder1/name1 [R=301,QSA,NC]
RewriteRule ^development_folder/(.*)$ $1 [QSA.NC]
RewriteRule ^subfolder1/folder1/name1$ script.php [QSA.NC]

Or is there a better way of doing it? Any hint would help a lot.