Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-19-2011, 11:38 PM   PM User | #1
mingis
New to the CF scene

 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mingis is an unknown quantity at this point
.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
mingis is offline   Reply With Quote
Reply

Bookmarks

Tags
htaccess, rewritecondition, rewriterule

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:35 PM.


Advertisement
Log in to turn off these ads.