Prakash Raman
Prakash Raman

Reputation: 13933

Htaccess rewrite if not path entered

I would like the webapp/index.php loaded whenever any path/page is requested for. Therefore I put the following in my htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /webapp/index.php?_path=$1 [L,QSA]

This work for any path, although is no page is given, it does not seem to work. How can I have the same rule applied when "/" is requested for ?

Upvotes: 2

Views: 248

Answers (2)

Felipe Alameda A
Felipe Alameda A

Reputation: 11809

Maybe this works:

RewriteRule ^($|.*) /webapp/index.php?_path=$1 [L,QSA] 

Or you may try this in case the .htaccess file is not at root or DirectoryIndex is not set:

DirectoryIndex index.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}  ^($|.*)          [NC]
RewriteRule .* /webapp/index.php?_path=%1 [L,QSA]

Upvotes: 1

anubhava
anubhava

Reputation: 785246

Replace .+ (one or more characters) by .* (0 or more characters). i.e.:

RewriteRule ^(.*)$ /webapp/index.php?_path=$1 [L,QSA]

Upvotes: 0

Related Questions