Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Stop RewriteRule blocking other content

Quote Reply
Stop RewriteRule blocking other content
I currently have the following in my .htaccess to make a dynamic site look static:

Code:
RewriteRule ^(.*).php /cgi-bin/links/page.cgi?g=$1.php [L]
RewriteRule New/(.*)$ /cgi-bin/links/page.cgi?g=New/$1 [L]
RewriteRule Ratings/(.*)$ /cgi-bin/links/page.cgi?g=Ratings/$1 [L]
RewriteRule Pop/(.*)$ /cgi-bin/links/page.cgi?g=Pop/$1 [L]

The problem is, anything else that I upload is regarded as a category and won't display.

Example 1: phpinfo.php in to root directory returns Category 'phpinfo.php' does not exist.

Example 2: /comments/admin/ directories in the root folder returns Category 'comments/admin' does not exist.

How can I get round this?

Last edited by:

MJB: May 6, 2011, 5:22 AM
Quote Reply
Re: [MJB] Stop RewriteRule blocking other content In reply to
OK sorted it for a single file by adding the following:

Code:
<Files phpinfo.php>
RewriteEngine Off
</Files>

Now just have to work out how to do it for a directory.

Crazy
Quote Reply
Re: [MJB] Stop RewriteRule blocking other content In reply to
You would need to do something like:

Code:
RewriteCond %{REQUEST_FILENAME} !phpinfo\.php$
RewriteCond %{REQUEST_URI} !directory_name
RewriteRule ^(.*).php /cgi-bin/links/page.cgi?g=$1.php [L]

RewriteCond %{REQUEST_FILENAME} !phpinfo\.php$
RewriteCond %{REQUEST_URI} !directory_name
RewriteRule New/(.*)$ /cgi-bin/links/page.cgi?g=New/$1 [L]

RewriteCond %{REQUEST_FILENAME} !phpinfo\.php$
RewriteCond %{REQUEST_URI} !directory_name
RewriteRule Ratings/(.*)$ /cgi-bin/links/page.cgi?g=Ratings/$1 [L]

RewriteCond %{REQUEST_FILENAME} !phpinfo\.php$
RewriteCond %{REQUEST_URI} !directory_name
RewriteRule Pop/(.*)$ /cgi-bin/links/page.cgi?g=Pop/$1 [L]

Basically, setting "conditions" just before each rule, which tell it to check if its true before the rule gets run.

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Stop RewriteRule blocking other content In reply to
Ah, that's where I was going wrong. I didn't realize that I had to do it for every line.

Thanks.
Quote Reply
Re: [MJB] Stop RewriteRule blocking other content In reply to
Yeah, I used to think that too Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Stop RewriteRule blocking other content In reply to
In relation to this......

Using the rules above, if the index.php isn't in the URL for the category it returns a 404.

1. www.mysite.com/directory1/index.php = OK
2. www.mysite.com/directory1/ = 404

Any way to avoid this?

Last edited by:

MJB: May 19, 2011, 9:50 AM
Quote Reply
Re: [MJB] Stop RewriteRule blocking other content In reply to
Mmm, you could try:

Code:
RewriteCond %{REQUEST_FILENAME} !phpinfo\.php$
RewriteCond %{REQUEST_URI} !directory_name
RewriteRule ^(.*)/$ /cgi-bin/links/page.cgi?g=$1.php [L]

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Stop RewriteRule blocking other content In reply to
Almost perfect. Just needed to remove the .php from the last line otherwise it displayed "Category 'Directory1.php' does not exist."

Code:
RewriteCond %{REQUEST_FILENAME} !phpinfo\.php$
RewriteCond %{REQUEST_URI} !directory_name
RewriteRule ^(.*)/$ /cgi-bin/links/page.cgi?g=$1 [L]

Thanks Andy.