CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Apache configuration (http://www.codingforums.com/forumdisplay.php?f=69)
-   -   .htaccess forwarding URL's (http://www.codingforums.com/showthread.php?t=241464)

mingis 10-19-2011 11:38 PM

.htaccess forwarding URL's
 
Newbie question sorry!

I have read the documentation on apache.org and I understand the basics, but the way rules interact with each other is confusing me!

I have the following .htaccess file, it checks whether a file or directory exists and ignores it if it does (because the page can load directly).

If the file does not exist it takes the last part of the URL and sends it to the redirect.php page of the CMS which serves up the page with a clean url e.g. /mywebsite.com/clean-url

I'm trying to rewrite some old CMS pages that no longer exist, but I'm not sure how the rules are interacting with each other - the best I can come up with is:

/mywebsite.com/old-url to /mywebsite.com/redirect.php?code=new-url

instead of:

/mywebsite.com/old-url to /mywebsite.com/new-url

I'd be really grateful for any advice based on my current .htaccess as below:

Code:

RewriteEngine on
RewriteBase /

# CHECK THE DIRECTORY OR FILE EXISTS
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
 
# IF YES DO NOTHING
RewriteRule ^.*$ - [L]

# OTHERWISE REDIRECT AND GET THE ID FROM LOAD PAGE
RewriteRule ([^/]+) /templates/redirect.php?code=$1

# REDIRECT OTHER PAGES
RewriteRule /old-url /new-url



All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.