0

Ok, I have a link http://www.cuadmemo.com/posts.php?id=2861 and want it to show like this http://www.cuadmemo.com/2861 I have in the .htaccess file this.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$  posts.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$  posts.php?id=$1

Have tried a number of different solutions that I read on this site but none seem to work this far. Any suggestions to fix this would be greatly appreciated.

1 Answer 1

1
RewriteEngine On
RewriteBase /

# Make sure we don't rewrite directories and existing files        
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)/?$ posts.php?id=$1 [L]
Sign up to request clarification or add additional context in comments.

4 Comments

few seconds faster than me, I deleted my answer :)
I added this to the .htaccess file but it still gives me the same result :(. I am pulling the data for the links in if statements to only post stories from the current day or previous day and ect. Does that have something to do with it? I am using hostgator as the web server provider under a reseller account if that helps.
Please try the updated answer with the RewriteBase directive
.htaccess can be used with Apache only, make sure your vhost config has the AllowOverride All directive, put the .htaccess file into your document root. Simple test to make sure the .htaccess is read at all is to add invalid markup - your browser will show an internal server error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.