Forum Moderators: phranque

Message Too Old, No Replies

Problems with an extra Rewrite Rule

I want to show 'domain.com/faq' and not 'domain.com/index.php?id=119'

         

guarriman

9:12 am on May 30, 2007 (gmt 0)

10+ Year Member



Hi.

I'm trying to create an additional Rewrite Rule appart from those created by default by my application (in this case, Wordpress). The extra line (within '.htaccess') is:
-------
RewriteRule ^faq index.php?page_id=119 [R,L]
-------

However, I want users see 'http://myblog.com/faq' and not 'http://myblog.com/index.php?page_id=379'. This line works with other Apache configurations, but not with mine. Any suggestion?

.htaccess
---------------------------------
RewriteEngine On
RewriteBase /
DirectoryIndex index.php

# MY OWN REWRITE RULES
RewriteRule ^faq index.php?page_id=119 [R,L]

# Rewrite www.domain.com to domain.com
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*) [%1...] [R,L]

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
------------------------------------------

jdMorgan

5:18 pm on May 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The URL seen by visitors is controlled by the link on your page, not by .htaccess. So change the link on your pages that link to /faq, and your rule will then forward requests for the /faq URL to your script.

More info about this process: [webmasterworld.com...]

For more information, see also the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

g1smd

8:20 pm on May 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> RewriteRule ^faq index.php?page_id=119 [R,L] <<

The [R] says that you want a Redirect. If you want an Internal Rewrite, then lose the R and keep the [L].

.

Your www to non-www redirect, specified by [R], is a 302 redirect. You'll need to change [R] to [R=301] to get this to work properly.

.

Currently your FAQ page responds for both www and for non-www requests. You might want to place your non-www to www request BEFORE your internal FAQ rewrite.