2

My htaccess is

Options -Multiviews

RewriteEngine On
RewriteBase /

# Force search engines to use www.mommy-info.com
RewriteCond %{HTTP_HOST} !^www\.mommy-info\.com$
RewriteRule ^(.*) http://www.mommy-info.com/$1 [R=301,L]

# Specify search friendly URLs
RewriteRule ^about/$ /about.php [L]

I've saved it, but it's not rewriting it on my website. It still shows the "ugly" urls. I'm not sure what to do, as I'm pretty new to the htaccess file and am not sure why it wouldn't work.

If I type in the "pretty" url (www.mommy-info.com/about/) it doesn't have the css, but it's the pretty url. If I go through the menu on the website it only displays the ugly urls.

Matt Clark
  • 27,671
  • 19
  • 68
  • 123
ethacker
  • 131
  • 1
  • 4
  • 17

1 Answers1

2

When I hit your site, it does appear as if mod_rewrite is working, things are just kinda off.

Whether I hit
    http://www.mommy-info.com/about.php
or
    http://www.mommy-info.com/about/
I am presented with the same content,

This can be seen with

$ curl http://www.mommy-info.com/about/ | md5
1105b8f6dbf1a2c52bddd8e5f9046653

$ curl http://www.mommy-info.com/about.php | md5
1105b8f6dbf1a2c52bddd8e5f9046653

The issue here actually seems to be with your main.css resource, which is referenced as:

<link href="main.css" type="text/css" rel="stylesheet"/>

The problem is that when I request /about/, the css file is referenced relatively, which fails; you can see this by inspecting in your browser and refreshing the page at /about/, the stylesheet will throw a 404.

$ curl --head http://www.mommy-info.com/about/main.css
HTTP/1.1 404 Not Found

To solve the stylesheet issue, change you line of code to access it from the document root, by prepending a / to the path, this will access it statically vs relatively.

<link href="/main.css" type="text/css" rel="stylesheet"/>
           /\ access statically from root

In addition to the stylesheet, you might want to remove all of the trailing slashes from your RewriteRules, as it forces the user to append the /, or a 404 will be seen:

$ curl --head http://www.mommy-info.com/about
HTTP/1.1 404 Not Found

$ curl --head http://www.mommy-info.com/about/
HTTP/1.1 200 OK
Community
  • 1
  • 1
Matt Clark
  • 27,671
  • 19
  • 68
  • 123
  • 1
    Thank you! I've fixed the trailing slashes, and am working on fixing the css relative access. Do you know why it's not showing the pretty urls when I access a page from the menu? – ethacker Apr 14 '17 at 20:55
  • 1
    Because your anchors are set to redirect the user to the .php file. `
  • About
  • ` Change them to `
  • About
  • ` – Matt Clark Apr 14 '17 at 20:58
  • 1
    Thank you so much! – ethacker Apr 14 '17 at 23:34