Question

404 redirect not working in htaccess - RewriteCond

Hey All,

I’m left scratching my head here, I have the following rule in my htaccess that is simply being ignored it would seem.

the idea is to redirect users coming in on older backlinks from:

http://domain.com/story.php?id=449

to

http://domain.com/?p=449
RewriteEngine On

RewriteCond %{QUERY_STRING} ^id=([^&]+) [NC]
RewriteRule ^story\.php$ /?p=%1 [L,NC,R=302]

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Ok AllowOverride is set to All (already) and I have tried a simple redirection and it works.

tail came up with the following, repeated lines so I pasted some as an example

[Thu Jul 09 10:23:17.711256 2015] [proxy_fcgi:error] [pid 12034] [client 10.132.65.228:36967] AH01071: Got error 'Primary script unknown\n'
[Thu Jul 09 10:23:25.637647 2015] [proxy_fcgi:error] [pid 12013] [client 10.132.65.228:36987] AH01071: Got error 'Primary script unknown\n'
[Thu Jul 09 10:23:50.170817 2015] [proxy_fcgi:error] [pid 12068] [client 10.132.65.228:37075] AH01071: Got error 'Primary script unknown\n'
[Thu Jul 09 10:24:05.804748 2015] [proxy_fcgi:error] [pid 12091] [client 10.132.65.228:37197] AH01071: Got error 'Primary script unknown\n'
[Thu Jul 09 10:24:23.446141 2015] [proxy_fcgi:error] [pid 12013] [client 10.132.65.228:37276] AH01071: Got error 'Primary script unknown\n'

Hi! Make sure .htaccess files are enabled and allowed to override settings. Edit the virtual host’s config file and set AllowOverride to All and restart Apache.

If that doesn’t work, please post the last few lines of Apache’s error log:

sudo tail -30 /var/log/apache2/error.log