Jump to content

SEF URLs: .htaccess settings


Malibu

Recommended Posts

Dear Community

 

Does anybody know how to achieve the following by modifying the .htaccess file in order to output SEF URLs:

 

a) remove the file extension .php and add instead a trailing slash

Example: instead of http://www.my-domain.tld/whatever.php, new http://www.my-domain.tld/whatever/

 

b) redirect the /index.php in the root to the domain

 

Found this in another thread of the community:

 

RewriteCond %{THE_REQUEST} ^GET\s.+\.php [NC]
RewriteRule ^(.+)\.php$ /$1 [NE,R=301,L,NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

 

But it does not add a trailing slash at the end of the rewritten files and the redirection of the /index.php in the root I've put in place is not working properly since the user can still call http://www.my-domain.tld/index although entering http://www.my-domain.tld/index.php is redirected correctly.

 

Many thanks in advance!

Link to comment
Share on other sites

Hello,

 

htaccess can be a pain as some code won't work on every server.

 

I personally use the following to redirect from /index.php to / but I use it for non-WHMCS pages, it may work for you:

 

RewriteRule ^(.*)index\.(php|html?)$ /$1 [R=301,NC,L]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated