0

I have been searching on the Internet for quite awhile now and I can't seem to find a working htaccess for my website. I am using a news CMS called CuteNews and they have a function that allows for URL rewrites. However, the URL rewrites caused the news pages to become .html as compared to all my other content pages which ends with a .php.

Instead of forcing the .html to .php or vice versa, I intend to remove both the .php and .html extension from the URL. However it can't work despite me putting a few different htaccess that other people had shown in the Internet.

Now, I am really a complete newbie at htaccess because I only have a very limited knowledge about it.

This is the .htaccess that CuteNews generates once I activate the URL rewrite functions,

# --- CUTENEWS[ST] RewriteEngine ON RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /cms/show_news.php?cn_rewrite_url=$1 [L] # --- CUTENEWS[ED] 

Can anyone guide me along or something on removing the .html generated by this .htaccess as well as to remove the .php from my other content pages? Thanks.

4
  • .htaccess RewriteRules don't remove the extensions from your code at all. They just make it so extension-less URLs work too. Your code needs to handle the extensions. Commented Mar 14, 2014 at 12:48
  • Forgotten to add this but I would love the URL to end with a trailing slash after the extension is remove. Commented Mar 14, 2014 at 12:48
  • 1
    This tool is very helpful: htaccess.madewithlove.be Commented Mar 14, 2014 at 12:48
  • @smdrager yes, but doesn't support the use of %{REQUEST_FILENAME} yet Commented Mar 20, 2014 at 7:53

1 Answer 1

1

To remove the .php or .html extension add the 2 last lines of this .htaccess extract in your htaccess file :

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] RewriteRule ^([^\.]+)$ $1.html [NC,L] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.