Forum Moderators: phranque
Then on index.php, have a file_exists check on $_GET['p'] and if true, use a header redirect to the page
Then if not, process the query string to redirect the user to an article or so for the general benefits of mod_rewrite - cleaner URL, SE friendly...
Other Benefits:
- Site easier to use
- No 404 errors
The only disadvantage I can think off is a small delay (because it calls index.php (which will be tiny (1kb or less)) and then the page that the redirect will go to.
Any feedback?
RewriteCond $1 !^/index\.php$
RewriteRule ^(.*)$ index.php?p=$1 [L]
Jim
Eg. If I type in [example.com...] how can I get nothing.php in the query string
ErrorDocument 404 /index.php?q=%{PATH_INFO}
I want something like that with nothing.php being the PATH_INFO
So it should generate
ErrorDocument 404 /index.php?q=nothing.php
Thanks,
Taner
This '404 content handling' method was one of those things that was invented by users of restrictively-configured shared hosting, as a work-around for the lack of mod_rewrite, cgi-scripting, etc. If you have any alternatives, I strongly suggest you use them.
IMHO, of course. ;)
Jim
I have a site where I have some folders and files
I also want users to be able to use the URL for easier site access, bookmarking and for SEO
So I would have two types of URLs
Some where the page actually exists eg.
http://example.net/forums
http://example.net/img/header.png
And some that will be processed
eg. http://example.net/php/security/sql
-> /index.php?p=/php/security/sql
which will then incldue the article for the sql page in the category PHP and sub-category security
I have thought of these methods:
1. Requiring a /q/ or similar before the URL of pages that will be rewrited.
eg. http://example.net/q/php/security/sql
-> /index.php?p=/php/security/sql
2. Define exceptions
eg.
RewriteCond %{PATH_INFO} ^!(forums¦img)
RewriteCond %{PATH_INFO}!\.[[:alpha:]]{2,5}$
3. Custom 404 errors but these won't work as these are not SE friendly as the above member wrote
Any other methods or suggestions to the above?
Thanks for any help in advance
Taner
[edited by: jdMorgan at 6:25 am (utc) on May 26, 2005]
[edit reason] No URLs, Please see TOS. [/edit]
It all comes down to which method you feel works best for your site.
Jim