0

Update: Is report a reserved word or some sort of special string in mod rewrite? I have changed the file name to report1 and the rules are working fine.

Original Question:

I cannot get a specific file /www/admin/report.php to work with my rewrite rules. I want to have the php extension removed and append a category value to the /admin/ path, like this:

https://url.com/car/admin/report 

But for some reasons the url only works with the extension present:

https://url.com/car/admin/report.php 

I have uncommented the other rules to test. Here are the rules that should remove the php extension:

RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L] RewriteCond %{THE_REQUEST} /index\.php [NC] RewriteRule ^([^\.]+)$ $1.php [NC,L] RewriteCond %{REQUEST_URI} /(admin|search)/(.*) RewriteRule ^(.*)/(.*)/(.*)?$ $2/$3?category=$1 [NC,QSA] // I make it less specific so it works with any filenames other than report.php as well 

I have tried adding .php to the last rule but that won't work either

RewriteRule ^(.*)/(.*)/(.*)?$ $2/$3.php?category=$1 [NC,QSA] 

Any help would be appreciated.

1
  • Is your .htaccess placed in /car/ directory? Also what is your last rule supposed to be doing? I don't see a requirement for ?category=... Commented Oct 5, 2015 at 8:43

1 Answer 1

1

You could try just using mod_negotiation, and ditch all your php extension rules. Just add the option somewhere in your htaccess file:

Options +Multiviews 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.