Reputation: 94
I want that when you go to url: http://www.example.com/subdir/paramvalue
redirects to
http://www.example.com/subdir/index.php?param=paramvalue
My .htaccess file is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^subdir/(.*) subdir/index.php?param=$1 [L,QSA]
But does not work. How can i do ?
Upvotes: 2
Views: 1301
Reputation: 784948
Place this rule in subdir/.htaccess
(not site root):
RewriteEngine On
RewriteBase /subdir/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php?param=$0 [L,QSA]
Upvotes: 2
Reputation: 94
Thanks anubhava ! First i edit 000-default from /etc/apache2/sites-available/ and add:
<Directory "/var/www">
AllowOverride All
</Directory>
Then the solution in .htaccess was:
RewriteEngine On
RewriteBase /subdir/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?param=$1 [QSA,L]
Finally in /subdir/index.php
I get the value paramvalue as:
$myParamValue = $_GET["param"];
echo myParamValue
it returns : paramvalue
Upvotes: 0