Abilash Erikson
Abilash Erikson

Reputation: 351

Htaccess redirection for url ending with dot(.)

I have a website and there is a booking page , booking.php . I want to redirect people who is typing dot(.) at the end of url to correct url .

For example some one type example.com/booking.php. then I have to redirect to example.com/booking.php How can I do this?

I tried and it is not working

Redirect 301 http://www.example.com/appointment.php. http://www.example.com/appointment.php 

Upvotes: 1

Views: 536

Answers (1)

Ravi Sachaniya
Ravi Sachaniya

Reputation: 1633

You can use RedirectMatch for that.

Check this code :

RedirectMatch 301 /appointment\.php\.$ /appointment.php 

Reference : https://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirectmatch


OR

You can use mod_rewrite to redirect it.

Check below code :

RewriteRule ^(.+)\.php\.$ $1.php [R=301,QSA,L]

Reference : http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule

Upvotes: 1

Related Questions