I am on a godaddy server now and trying this mod-rewrite stuff and it is still not working.
I have been searching google now for hours looking for the answer and cannot find it.

Here is my entire .htaccess file:
#Rewrite Rules
Options -MultiViews
Options +FollowSymLinks +Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)(/?)$ index.php?p=$1 [L]

#RewriteEngine On
#RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME}.php -f
#RewriteRule ^(.+)$ /$1.php [L,QSA]
#RewriteRule ^c/([^/.]+)/?$ index.php?p=$1 [L]


The stuff thats commented out is what I tried the first time, then I tried many many other ways to try and get this to work with no luck.
Thanks,
Brian

Dani AI

Generated

Brief summary and diagnosis: reported that pretty URLs did not appear to work, but demonstrated that a clean path returned the expected page — which indicates Apache was honouring rewrite rules. The effective gap was that the application was still emitting query-string links (index.php?p=...), so the visible behavior looked like “nothing changed.” ’s example showed the simplest mapping to a .html slug; the remaining step was to make the app generate those slugs (or to add a rewrite that accepts the existing link format).

Common checks and gotchas:

  • Confirm the file is actually named exactly .htaccess in the document root (some FTP tools strip the leading dot).
  • Ensure the host parses .htaccess (a quick temporary test directive will reveal whether Apache reads it) and that file permissions and encoding are sane (644 and UTF-8 without BOM).
  • Verify the host allows rewrite overrides for that directory (AllowOverride must permit rewrites on the server side).
  • Make sure internal links/templates output the clean paths or the rewrite cannot change what the browser requests.

A minimal, robust pattern for multi-segment clean URLs (skip real files/dirs, preserve query strings) can be used as the routing basis inside the document root:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# let existing files and directories pass through
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# map clean path segments (letters, digits, -, _) to index.php?p=...
RewriteRule ^([A-Za-z0-9_-]+(?:/[A-Za-z0-9_-]+)*)/?$ index.php?p=$1 [L,QSA]
</IfModule>

Practical notes: update the site’s link-generation (templates or routing code) to emit the clean paths, test with curl -I and server error logs if it still fails, and contact the host if AllowOverride appears disabled. This sequence explains why saw no change until the links themselves were adjusted.

Recommended Answers

All 10 Replies

Anyone have any insight on this?

... the weird thing is I got an email saying someone replied to this and I dont see anything.

What do you mean with "is not working"?
Your rule RewriteCond %{REQUEST_FILENAME}.php -f requests that for a request like /abc the file named /abc.php exists. Is that what you want?
Your last rule will never catch anything in its second pair of brackets. In RewriteRule ^(.*)(/?)$ index.php?p=$1 [L] the first bracket pair catches all content.

My goal is to get a domain like this domain.com/training or domain.com/contact instead of domain.com/index.php?p=training.

I have checked numerous sites even a thread on here doing the same exact thing using the same exact example, and i believe he was also using a godaddy server. I used his same code and got nothing, eventually just confused myself because I have used so many different snippets from all over.

Anyone have any insight on this?

... the weird thing is I got an email saying someone replied to this and I dont see anything.

This happened because a spammer replied to your thread, but then a moderator deleted their post.

Try the .htaccess file:

RewriteEngine On
RewriteRule		^([a-z0-9]+).html$		index.php?p=$1	[L]

Then, blah.html will redirect to index.php?p=blah

I have your code in there right now and its still not working. I almost positive that is something I have tried before also.

You can check it out at http://kbrlifestyles.com and just click on a link to see what I am talking about.

ok I see, so I actually need to change the link from "index.php?p=contact" to just "/contact"

This would not happen automatically?

There is nothing in the IT world which happens automatically.
To make the /contact link work, you'll first have to install the modification from my previous post.

Yeah, well it works. thats all that matters to me.

Thanks a bunch!!

Please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.