RE: [users@httpd] Need a mod-rewrite rule for a website's home page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, I've been playing with my rewrite rules, my database and PHP scripts, and it looks like I've come full circle. The home page is previewing dynamic URL's correctly. I have to fix a few things before I can really test the various sections, but I can bring up "pseudo-pages" when I type in URL's like mysite/About/New and mysite/About/Webmaster, so it looks like the section home pages are also previewing dynamic pages like they're supposed to.

The problem is the truncated version of the section home pages, like mysite/About and mysite/People. As I noted earlier, my site's home page displays URL's consisting of the names of various places, drawn from a database table; for example, mysite/Arizona. If I type in something that doesn't exist in my database, like mysite/xxx, it's rigged to bring up a custom error page.

However, I added a PHP switch to handled things like mysite/About and mysite/Reference. In fact, it works fine when I type in mysite/People.

But if I type in http://gw/About, it defaults to http://gw/About/?home=About, triggering the error page. Similarly, http://gw/Reference defaults to http://gw/About/?home=Reference

Is this something I can fix with RewriteCond? If so, can someone show me how to do it?

Also, I just discovered that this problem occurs only if there is a page in the matching folder, even if that page has no text or html at all. For example, if there's a page at mysite/Reference/index.php, then the URL mysite/Reference defaults to http://gw/Reference/?home=Reference. If I delete that page, then the URL correctly displays as http://gw/

So I suppose an alternative is to simply modify the home page rewrite rule --

RewriteRule ^/?([-a-zA-Z0-9_/]+)/?$ /index.php?home=$1 [L]

...so that it isn't "distracted" when a dynamic URL matches the name of a static web page.

Below is a copy of my entire .htaccess file. Thanks!

* * * * * * * * * *

# GEOWORLD
RewriteEngine On

RewriteRule ^About/([a-zA-Z0-9()_/-]+)/?$ About/index.php?bout=$1 [L]
RewriteRule ^People/([a-zA-Z0-9()_/-]+)/?$ People/index.php?man=$1 [L]
RewriteRule ^Reference/([a-zA-Z0-9()_/-]+)/?$ Reference/index.php?ref=$1 [L]
RewriteRule ^/?([-a-zA-Z0-9_/]+)/?$ /index.php?home=$1 [L]


Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux