Reputation:
What I will use instead of Document_Root in .htaccess??
Following is in my htttp.conf of my linux server.
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php -f
RewriteRule ^/(.*)(/?)$ /$1.php [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})(/?)$ /profile.php?fairid=$1$2 [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})/([a-z]*)(/?)$ /$3.php?fairid=$1$2 [L]
But now I shifted my domain to shared server. So for running my site properly what changes will be needed in .htaccess in rewrite rules?
My .htaccess is as follows:
RewriteEngine On
RewriteBase /~laborfa2
RewriteCond %/~laborfa2/lf/main/com/%{REQUEST_FILENAME}.php -f
RewriteRule /(.*)(/?)$ /~laborfa2/lf/main/com/$1.php [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})(/?)$ /~laborfa2/lf/main/com/profile.php?fairid=$1$2 [L]
But it is not working. Please suggest the changes will be needed in .htaccess.
Upvotes: 0
Views: 106
Reputation: 655509
REQUEST_FILENAME
already is an absolute file system path and prepending DOCUMENT_ROOT
is wrong.
Additionally, when using mod_rewrite in a .htaccess file, Apache strips the per-directory path prefix from the requested URI path before testing the rules. And in case of the .htaccess file in the document root of the web server, it’s the leading /
that’s stripped of. So your pattern must not begin with a leading slash like in the server or virtual host configuration.
So try this:
RewriteBase /~laborfa2/
RewriteCond %{DOCUMENT_ROOT}~laborfa2/lf/main/com/$1.php -f
RewriteRule (.*)(/?)$ /lf/main/com/$1.php [L]
RewriteRule ^([a-zA-Z]+[a-zA-Z0-9_]{3,15})(/?)$ /lf/main/com/profile.php?fairid=$1 [L]
Upvotes: 1