5

Actually I need to add index.php in my application URL through htaccess file.

My URL is like this.

http://localhost:8080/myapp/xyz/abs.html

I need to change this into.

http://localhost:8080/myapp/index.php/xyz/abs.html

Can anyone tell me what i need to be write in htaccess file.

Any Help will be appreciating.

Thanks.

1
  • are you using any framework ?, what is your current .htaccess ? Commented Jul 6, 2015 at 6:53

3 Answers 3

5

Have this rule in /myapp/.htaccess:

RewriteEngine On
RewriteBase /myapp/

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+) index.php/$1 [L]
Sign up to request clarification or add additional context in comments.

Comments

1

Presumably an internal rewrite is required, not an external redirect? In which case, try something like the following, using mod_rewrite in your root .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_URI} !/index\.php/
RewriteRule ^myapp/(.*) /myapp/index.php/$1 [L]

The RewriteCond directive is required to prevent a rewrite loop. (Only rewrite if it doesn't already contain "/index.php/".)

Comments

0

Try this in your htaccess

RewriteEngine on 
RewriteCond %{THE_REQUEST} /myapp/xyz/([^.]+)\.html [NC]
RewriteRule ^ /myapp/index.php/xyz/%1.html [R,L,NC]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.