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 09-02-2011, 02:32 AM   PM User | #1
RanDeh
New to the CF scene

 
Join Date: Sep 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
RanDeh is an unknown quantity at this point
Question htaccess Mod_Rewrite 404 error

Hi Everyone,

I am trying my hand at a mod_rewrite, although I keep getting a 404 error and from the url if it did work I would not get the results I am looking for. I want to drop the articledetail.php only and keep everything else or is this just impossible. I am hopeful someone here can help me out.

Thanks,

This what I get with the 404 error:

http://www.articlefinder.info/793/90...-the-Best.html

This is what I want:
http://www.articlefinder.info/artid=...-the-Best.html

Code:
RewriteEngine on
# Mod Rewrite
Options +FollowSymLinks
#Fix Rewrite
Options -Multiviews
Rewritebase /
RewriteRule ^\.htaccess$ - [F]

RewriteCond %{THE_REQUEST} ^[^/]*/articledetail\.php [NC]
RewriteRule ^articledetail\.php(.+) $1 [R,L]

#Rewrite Rules and conditions below were already in the script and work.
RewriteCond %{REQUEST_METHOD} ^PUT$ [OR]
RewriteCond %{REQUEST_METHOD} ^MOVE$
RewriteRule ^/author/(.*)\.php /author/$1.nophp
RewriteRule ^/author/(.*)\.html /author/$1.nohtml
RewriteRule ^/author/(.*)\.htm /author/$1.nohtm
RewriteRule ^/author/(.*)\.js /author/$1.nojs
RanDeh is offline   Reply With Quote
Old 09-02-2011, 02:51 PM   PM User | #2
Cags
New Coder

 
Join Date: Jul 2011
Posts: 67
Thanks: 0
Thanked 13 Times in 13 Posts
Cags is an unknown quantity at this point
Sounds like you are misunderstanding the point of what mod_rewrite does (which is REALLY common). It is intended to take a request for one URI and serve some resource from your actual server.

In your case if Apache receives a request to the server for /author/foobar.php, it would attempt serve up the file /author/foobar.nophp. I'm assuming this isn't actually a file on your server. Assuming you want to achieve the common task of URL's on your site not having file extensions, then you need to flip your view of how it works. At it's most basic you would have something like...

Code:
RewriteRule ^/author/(.*)/?$ /author/$1.php
This will then take requests for /author/foobar and serve the file located at /author/foobar.php, therefore you must then change all URLs on your site to point to the extension less path.

NB. If you have this code in your .htaccess file, not in a Vhost file, then the very first forward slash doesn't want to be there.
Cags is offline   Reply With Quote
Old 09-02-2011, 03:52 PM   PM User | #3
RanDeh
New to the CF scene

 
Join Date: Sep 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
RanDeh is an unknown quantity at this point
Hi Cags,

Thanks for taking a look! The reason I want to drop the articledetail.php is just to cleanup the look. I want to keep the following because Google uses them as URL parameters's and by me defining the effect on the content my crawled pages went from 26 to 1,059 in one day. Today it is 1,103 but I understand that's not page ranking at least they are indexed. Maybe it would be best not to mess with it.

Any other input is welcomed!

Regards,

Keep: artid=793&catid=90&title=
RanDeh is offline   Reply With Quote
Reply

Bookmarks

Tags
404 eror, htaccess, mod_rewrite

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 08:49 AM.


Advertisement
Log in to turn off these ads.