skip to Main Content

Please help me regarding this issue. I just want to

  1. Remove .php extension from my files, which is very well done by this
    code.
  2. Convert complex php urls to seo friendly urls.

My htaccess file is

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [L]
RewriteEngine on
RewriteRule ^search_contents/([0-9]+) search_contents.php?txt_search_contents=$1 [NC,L]

3

Answers


  1. try this

    RewriteRule ^search_contents/([0-9]+)$ search_contents.php?txt_search_contents=$1 [NC,L]
    
    Login or Signup to reply.
  2. If your search_contents.php is at the root of your project directory then try the following :-

    RewriteEngine on
    RewriteBase /
    RewriteRule ^search_contents/(.*)$ search_contents.php?txt_search_contents=$1 [L,R=301]
    

    If it is in any folder then try the following :-

    RewriteEngine on
    RewriteBase /
    RewriteRule ^search_contents/(.*)$ myfolder/search_contents.php?txt_search_contents=$1 [L,R=301]
    

    1) I have added RewriteBase

    2) ([0-9]+) to (.*), Allow all the parameters instead of only numbers If you required this you can change to number.

    It may help you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search