Forum Moderators: phranque
I want it to be:
page_result.html
Here is what I am placing in my htaccess, but it isn't working.
RewriteRule ^([^./]+)\.html$ page.php?result=$1&%{QUERY_STRING} [NC,L]
I have tried other methods that worked fine. But currently, I have one of the pages already posted, but it's static. I'd like to make it's counter-part pages have a similar URL structure, if possible.
Not quite. As g1smd says, you must put a link to page_result.html on your Web pages. This defines the URL for all the world to use.
Then mod_rewrite is used to detect requests for that URL, and rewrite them to page.php?result=resultnamehere so that your page.php script is invoked to produce the desired page.
mod_rewrite cannot change a URL; It can only "reconnect" a search-engine-friendly static URL with the script needed to produce the content for that friendly URL.
If you do not change the links on your pages, then your only option is to use 301-Moved Permanently redirects on every 'unfriendly' URL request to redirect the requests to the friendly URL. This involves an additional HTTP transaction per request, and therefor doubles your server load (for those URLs) and slows the visitor experience. Once the redirect is accomplished, you once again have to use an internal rewrite to provide content for the now-friendly requested URLs. So the bottom line is that the links on a page define the URLs that the world uses, and that mod_rewrite cannot change those on-page URLs except by using an external redirect -- Which is neither efficient nor 'transparent'.
Jim
> And anyway, a proper rewrite should work simply by typing the re-written URL into my browser's address bar.Not quite. As g1smd says, you must put a link to page_result.html on your Web pages. This defines the URL for all the world to use.
upside, I tried your rewrite and no luck.
Is this type of rewrite only possible in this fashion:
RewriteRule ^page/([^.]+)\.html$ page.php?result=$1&%{QUERY_STRING} [NC,L]