Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL Rewrite Issue with Mango Blog (404 error)

I am working on setting up an instance of Mango Blog on an Ubuntu Server running Apache 2 HTTPD and Tomcat 6 with Railo 3.1.2. I was able to get everything setup until I started trying to implement URL rewriting for the blog URLs.

I used a combination of Adam Tuttle's and John Sieber's posts to get the rewrite rules. I have the site setup as follows:

{webroot}/.htaccess

RewriteEngine on
RewriteBase /
# archives rule must be located before page rule for paging to work correctly
RewriteRule archives/(.*)$              archives.cfm/$1 [PT,L,NC]
RewriteRule page/(.*)$                  page.cfm/$1 [PT,L,NC]
RewriteRule post/(.*)$                  post.cfm/$1 [PT,L,NC]
RewriteRule author/(.*)$                author.cfm/$1 [PT,L,NC]

{apache-home}/sites-enabled/sitename

<VirtualHost *:80>
        ServerAdmin *******

        DocumentRoot /var/www/******/www
        ServerName mango.*****.com
        DirectoryIndex index.cfm

        <Directory /var/www/*******.com/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/error-*******_com.log

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

        CustomLog /var/log/apache2/access-********_com.log combined

        ProxyPreserveHost Off
        ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://********.com:8009/

</VirtualHost>

When I visit blog posts by going to /post/hello-world on the site I get a 404 error. If I go to /post.cfm/hello-world the post comes up just fine. I tried the rewrite rules against a rewrite tester, and that said that the rewrites should work fine. I am very new to rewriting, so I apologize if this is something simple.

like image 271
Dave Long Avatar asked May 12 '11 19:05

Dave Long


People also ask

Is URL rewrite safe?

URL rewriting and security are two different things. The URL rewrite simply changes the presentation of variables in the url but does not secure at all. We must secure the variables in your code after you recover from the url.

What is URL rewriting in PHP?

Create Rewrite Rule This rule matches any requested URL; if the URL does not correspond to a file or a folder on a file system, then the rule rewrites the URL to Index. php and determines which content to serve based on the REQUEST_URI server variable that contains the original URL before it was modified by the rule.

What is URL rewrite in Apache?

URL rewriting purpose is to change the appearance of the URL to a more user-friendly URL. This modification is called URL rewriting. For example, http://example.com/form.html can be rewritten as http://example.com/form using URL rewriting.


1 Answers

Put in your .htaccess file:

Options -Multiviews
like image 73
akond Avatar answered Nov 08 '22 23:11

akond