M
M
MonsterAndrew2017-09-30 23:30:57
Apache HTTP Server
MonsterAndrew, 2017-09-30 23:30:57

How to make /123 seen by Apache as /index.php?name=123?

There are index.php, ads.php and about.php pages and using .htaccess the .php extension is hidden like this:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.*) $1.php

You need to make sure that if RewriteCond %{REQUEST_FILENAME}.php !-fthe request /hahah and /asdjf are perceived as /index.php?name=hahah and /index.php?name=asdjf respectively. I tried with code like this:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.*) $1.php 
RewriteCond %{REQUEST_FILENAME}.php !-f
RewriteRule (.*) index.php?name=$1

But it doesn't work. Kind people help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sisyukin, 2017-10-01
@MonsterAndrew

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ index.php?name=$1 [L,QSA]
# и тд  если надо
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)$ index.php?name=$1&sub_name=$2 [L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question