Elcid_91
Elcid_91

Reputation: 1681

htaccess to direct php file request only

I want to set up my htaccess to redirect just my php file request only. My htaccess file is set up like so:

Options +FollowSymlinks

RewriteEngine On

RewriteBase /client

RewriteCond %{REQUEST_FILENAME} !index\.php
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule ^(.*)$ /index.php?request=$1 [L,QSA]

But a call to a php file via ajax does not redirect to the index.php. What am I not doing correctly? Thanks.

The URL begin sent is:

http://192.168.1.200/client/test.php?_dc=1438796049168&sr=ca8dfff9-e845-11e4-9d37-2637a38bcd64

Upvotes: 2

Views: 401

Answers (2)

anubhava
anubhava

Reputation: 785266

You can replace your rule with this rule:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /client/

RewriteCond %{REQUEST_URI} !index\.php$ [NC]
RewriteRule ^(.+?\.php)$ index.php?request=$1 [L,QSA,NC]

Upvotes: 1

sa289
sa289

Reputation: 700

Try removing the RewriteBase line and the slash in front of /index.php and put it in a .htaccess file in your client folder, not in the parent folder (assuming that's the case currently). I tested this and confirmed that appears to do what you're wanting it to do. For example:

In /client/.htaccess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !index\.php
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule ^(.*)$ index.php?request=$1 [L,QSA]

Upvotes: 0

Related Questions