Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8201705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:54:20+00:00 2026-06-07T06:54:20+00:00

I use this rewrite: RewriteRule post-(.*)\.html$ post.php?id=$1 but have since changed the file name

  • 0

I use this rewrite:

RewriteRule post-(.*)\.html$ post.php?id=$1

but have since changed the file name post.php to photo.php so i changed it to

RewriteRule photo-(.*)\.html$ photo.php?id=$1

which is fine but I have been getting errors in my logs when visitors come from search engines and get directed to original file name post.php?id=? so need to add (I think) a 301 redirect, I have tried:

RewriteRule photo-(.*)\.html$ post.php?id=$1

and:

RewriteRule photo-(.*)\.html$ post-(.*)\.html$[L,R=301]

but neither work and to be honest haven’t really got a clue, please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:54:23+00:00Added an answer on June 7, 2026 at 6:54 am

    I think you want it to be the other way around. When people go to your old URL (post.php?id=), redirect to the new one. You either want one of these:

    RewriteRule post-(.*)\.html$ photo-$1.html [R=301]
    
    RewriteRule post\.php$ photo.php [R=301]
    

    The first takes a URL like http://hostname.com/post-1234.html and redirects the browser to http://hostname.com/photo-1234.html so your rules can rewrite it to photo.php, the second does the same except http://hostname.com/post.php?id=1234 to http://hostname.com/photo.php?id=1234 (note that the query string automatically gets appended to the end in the second rule).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I have my urls set up to rewrite news_item.php?id=1 to blog/1/Title-of-post. This works
So I was able to use this code: RewriteRule ^portfolio$ _pages/_portfolio/port.html [NC,L] to rewrite
I have this addrress http://mysite.com/index.php?cat=7 I write this mod rewrite RewriteRule ^category/(\d+) index.php?cat=$1 this
I want to rewrite http://website.com/?slug=product_info.php&products_id=32 to http://website.com/product_info/32 and I use this code, add_filter('rewrite_rules_array','wp_insertMyRewriteRules'); add_filter('query_vars','wp_insertMyRewriteQueryVars');
I have this rewrite rule that turns foo.com/test (or foo.com/test/) into foo.com/test.txt: RewriteRule ^test/?$
RewriteEngine on RewriteCond $1 !^(index\.php|images|css|robots\.txt) RewriteRule ^(.*)$ index.php?p=$1 [L] I use this to forward
I have this: RewriteRule ^show_shop/([0-9]+)$ show_shop.php?id=$1 [NC] When entering the url like this: domain.com/show_shop/4
I'm trying to work with mod_rewrite without particular problems but this: RewriteRule ^(product/)([^/\<\>].+?)(/)([^/\<\>].+?)(/edit)/?$ php/prd_edit.php
I use this rule so all URLs have a trailing slash rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/
these are the rewrite rules I normally use for clean urls, RewriteRule ^([a-zA-Z0-9\-]+)/?$ index.php?pg_url=$1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.