Forum Moderators: phranque

Message Too Old, No Replies

applying rewrite to two targeted files?

         

nvhack

6:27 pm on Sep 26, 2008 (gmt 0)

10+ Year Member



Hi,

Basically what I'm trying to do is have a separate admin.php control panel that is not part of my frontend index.php The index.php is working as intended with search engine friendly urls redirected to the index page.

index.php/animals/cats (working great)

Is it possible to have another file if present receive query data? currently, I able to get to my admin.php and admin/index.php file but no query data is passed.

admin.php?login=do
or in subdirectory
admin/index.php?login=do

.htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /mycms
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) $1 [L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /mycms/admin/index.php?p=$1&b=$2&c=$3 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ index.php?category=$1 [L]
RewriteRule ^(.+)$ $1/ [L,R=301]

jdMorgan

6:56 pm on Sep 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put your external redirect (R=301) rule first. An external redirect should specify a full canonical URL: "http://www.example.com/$1/"

Then put your internal-rewrite rules, in order from most-specific/most-complicated pattern, to least.

As it stands now, any URL which might match the second rule will have already matched the first rule, so the second rule will never be invoked.

There must be some difference in the requested URL so that the RewriteRules can tell which of them should execute by matching the URL to a pattern.

End all rules with an [L] flag, in addition to nay others, unless you know the specific reason you don't want to use it.

Jim