0

Here i'm facing problem with rewriting url. I'm using php(ver. above 5.0) with xampp.

My current url is
Original url : /localhost/test/signup.php
redirect Url : /localhost/test/signup/

I wrote rewrite rules in htdocs

  RewriteEngine On
  RewriteBase /test/
  RewriteRule ^signup/$ signup.php

it's not working. I was changed httpd.conf setting also. but no use.

NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
dinesh Kumar
  • 61
  • 4
  • 16

2 Answers2

0

use below working code for me to hide .php extension.

RewriteEngine On

# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L]

# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L]

# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
liyakat
  • 11,825
  • 2
  • 40
  • 46
  • Thank you, but its asking create separate folder in project folder. is it possible to without folder – dinesh Kumar Sep 18 '13 at 04:52
  • you can remove from http of folder name and try – liyakat Sep 18 '13 at 04:57
  • RewriteBase /test/ RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/$ $1 [R=301,L] # Redirect external .php requests to extensionless url RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/ RewriteRule ^(.+)\.php$ $1 [R=301,L] # Resolve .php
    file for extensionless php urls RewriteRule ^([^/.]+)$ $1.php [L]
    as per your code i was edited like above for my requirement. for example i'm clicking product.php to redirect its test/product. but it showing page not found error. its asking product folder. is it possible to avoid this. thank you
    – dinesh Kumar Sep 18 '13 at 05:00
  • How to pass post variable through this rewrite urls. – dinesh Kumar Sep 18 '13 at 06:52
  • post variable is from form you have to use get – liyakat Sep 18 '13 at 06:59
0

What error you are getting?

Meanwhile you may try with this

RewriteEngine On
RewriteBase /test/
RewriteRule ^(signup)$ signup.php [L]

for all php files:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
G S Bajaj
  • 84
  • 1
  • 7