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

Quick checklist and a small, safe test for (and thanks for the location check): confirm the file is really named exactly .htaccess (not htaccess.txt) and that it sits in the document root you expect. A minimal rewrite test will show whether mod_rewrite is running at all — put a simple rule (below) in .htaccess, create rewritetest.txt with plain text, then request http://yourdomain/rewritetest. If it serves the text, mod_rewrite is active.

# quick test — create rewritetest.txt and then request /rewritetest
RewriteEngine On
RewriteRule ^rewritetest$ rewritetest.txt [L]

If that fails, check the server error log first (a 500 or an “Option … not allowed here” message is common) and ask the host whether mod_rewrite is enabled for your account. The mod_rewrite engine and per-directory rules are documented in the Apache manual. (httpd.apache.org)

Common GoDaddy/shared-host gotchas to try next: many hosts block or change Options +FollowSymLinks (or won’t allow overriding it), so having an Options line can trigger a 500. If you see that error, replace or remove the FollowSymLinks option (some hosts allow Options +SymLinksIfOwnerMatch) or comment out the options temporarily. Also keep MultiViews off — it can hijack extensionless requests. (httpd.apache.org)

If mod_rewrite is active but your rules still misbehave: avoid patterns that match the empty string (e.g. ^(.*)(/?)$) because they can capture / and create unexpected rewrites/loops. Prefer a non-empty pattern and add QSA if you need query-string preservation. You can also test by excluding index.php from rewrites to prevent self-matching. The per-directory matching rules and RewriteBase details are in the docs. (httpd.apache.org)

For debugging, check the account error log (cPanel or hosting dashboard), and if support can temporarily raise rewrite logging (or show the error_log), it will pin down which rule fires. Many people with GoDaddy have reported subtle config differences; if the simple test works but your full rules don’t, paste the minimal failing rule and the exact error_log line and the community can diagnose the pattern. (httpd.apache.org)

Recommended Answers

All 2 Replies

Is the .htaccess file in the same folder as the files you are targeting with it? Also, you may try ask the folks in the Linux Servers and Apache forum too ;)

Yes, the files are directly in the root folder. I will also try out that forum, thanks.

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.