Currently I am working with a php script but it still contains an unfriendly link (cms.php?Cms=login).

I want to turn it into a friendly link


I have an .htaccess file is created

RewriteEngine On
RewriteRule ^cms/([^/]*)$ /cms.php?cms=$1 [L]

But when in now go to the page I see this:

enter image description here

My /etc/apache2/sites-available/default file:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

Also did this:

sudo a2enmod rewrite

sudo service apache2 reload

rewrite.load file:

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

I looked on much forums but I cannot find it. Ubuntu server works on openvz (ubuntu 12.10)

Where is the fault ? what should I do ?

  • In the screenshot you post, you're requesting URL /cms/index.html/, but your rewrite rule does not match it ^cms/([^/]*)$. Please include in your question the exact requirement for your rewrite. What do you want to accomplish (and what you do not)? Do you want the full path after /cms/ to be rewritten to a parameter? Or just the first word until the next /? It looks like you have a requirement about the slash, referring to your current regular expression. – gertvdijk Jun 20 '13 at 22:15
  • I mean this one. using the generator of generateit.net/mod-rewrite RewriteEngine On RewriteRule ^cms/([^/]*)$ /cms.php?cms=$1 [L] i.stack.imgur.com/Lj5uT.png I want cms/login if this is probable. But I am not sure if the rewrite function is working. – Daan Seegers Jun 21 '13 at 0:36
  • @DaanSeegers in your screen shot, you have .html/ at the end of the link. According to your rewrite rule, it should be /cms/login instead of /cms/login.html/. Does your problem persist after you removed the .html/? – Dan Nov 18 '13 at 11:02

try this:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^cms\login$ cms.php?Cms=login [L]

You should notice that you type cms.php?Cms=login with 'C' uppercase, it is different with 'c' in lowercase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.