Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

/cms/login

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>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

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

        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
</VirtualHost>

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 ?

share|improve this question
    
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

1 Answer 1

try this:

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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