Forum Moderators: phranque
This means for example there are files like this.
/dirA/#*$!.php
/dirA/yyy.php
/dirA/zzz.php
/dirB/xxx.php
/dirB/yyy.php
/dirB/zzz.php
/dirC/xxx.php
/dirC/yyy.php
/dirC/zzz.php
And so on.
I have been doing some reorganising and have altered the names of some of the files, thoughout the directories, so that
/dirA/xxx.php becomes /dirA/vvv.php
/dirB/xxx.php becomes /dirB/vvv.php
/dirC/xxx.php becomes /dirC/vvv.php
In other words the page name changes are the same accross a number of directories.
I know I could list all the pages and the ones they should redirect to, but I don't know how to say something like:
In any directory files that were xxx.php are now vvv.php and ones previously called yyy.php are now ttt.php
I imagined something like this:
RewriteEngine on
RewriteRule ^xxx.php$ vvv.php
RewriteRule ^yyy.php$ ttt.php
but that is not working. Anyone able to help?
RewriteEngine on
RewriteRule ^/#*$!\.php$ /vvv.php
RewriteRule ^/yyy\.php$ /ttt.php
Keep in mind that those rules will only work for files that are in the same dir as the .htaccess file. You'd have to put that same .htaccess file in all the dirs. If you have multiple dirs, then I'd use something like this:
RewriteEngine on
RewriteRule ^(.*)xxx\.php$ $1vvv.php
RewriteRule ^(.*)yyy\.php$ $1ttt.php
The parens are for back-referencing. So, any file named xxx.php or yyy.php, in any dir will be rewritten and the dir will be prepended.
Hope I made sense there :) Definately check the documentation out for more info.
[httpd.apache.org...]
Cheers
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)#*$!\.php$ /$1vvv.php [L]
RewriteRule ^(.*)yyy\.php$ /$1ttt.php [L]
The main point is that you may need the Options directive at the top to enable mod_rewrite.
Jim
What would it look like if you had hypens or underscores in the page name? Would it look like this?
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)oldpagename\.php$ /$1old-page-name.php [L]
RewriteRule ^(.*)olderpagename\.php$ /$1older_page_name.php [L]
I use a lot of underscores and hyphens.
Thanks,
Jim
Is the above example suppose to automatically redirect people to the respective pages? If so, I am at a loss here. I have followed the example to the letter and my error log still shows "file not found" errors for my old page names.
I have been able to redirect the old pages to the new pages using an actual redirect.
I don't know if this makes a difference or not, but I am trying to do this.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/olddirectory/oldpage\.htm$ /$1new-page-name.htm [L]
Do you have any suggestions? Thanks in advance for your help. :-)
Jim
RewriteRule ^olddirectory/oldpage\.htm$ /new-page-name.htm [L]
If you will define what directory you wish to put the .htaccess mod_rewrite code in, what URLs you wish to rewrite, where you want to rewrite them to, which parts of the old URLs are fixed and which are variable, and the relationship of the new destination directory to the directory in which the mod_rewrite code resides, that will make a good start to defining the problem. The coding is not difficult; The difficulty is in defining the problem precisely enough so that everyone looking at this thread can understand it.
Jim
Thanks :-) The last piece of advice worked. I apologize for the confusion. I have been trying multiple variations of various posts through this topic and other topics within this forum.
The last method has worked wonderfully. Is there a book like .htaccess for dummies? I would be interested in such a book. I can see the beauty and power of the .htaccess file.
Once again thanks for your time.
Jim