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 8129937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:30:03+00:00 2026-06-06T08:30:03+00:00

I’m using the following in my .htaccess file but it doesn’t seem to be

  • 0

I’m using the following in my .htaccess file but it doesn’t seem to be working correctly.

Redirect 301 top_users.php http://example.com/top-users
RewriteRule ^top-users/?$ top_users.php

Redirect 301 register.php http://example.com/register
RewriteRule ^register/?$ register.php

Redirect 301 register.php?log=1 http://example.com/login
RewriteRule ^login/?$ register.php?log=1

The top users page seems to be working fine, and it works fine if i go straight to /login or /register, but the redirect isn’t working. I’ve tried adding a forward slash before the redirect page name but it gives me the wrong path and says it cannot be found.

Any ideas?

EDIT:

UPDATE:

The final code i used was as below, thanks to Jon Lin for the help.

RewriteEngine On
RewriteBase /
Options +FollowSymLinks

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /top-users(/|$|\ )
RewriteRule ^top-users(/|$|\ ) top_users.php [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /top_users\.php
RewriteRule ^top_users\.php$ http://example.com/top-users/ [R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /register(/|$|\ )
RewriteRule ^register(/|$|\ ) register.php [L]

# check if request for register.php does not include log=1 in query string
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /register\.php
RewriteCond %{QUERY_STRING} !log=1
RewriteRule ^register\.php$ http://example.com/register/ [R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /login(/|$|\ )
RewriteRule ^login(/|$|\ ) register.php?log=1 [L,QSA]

# check if request for register.php includes log=1 in query string
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /register\.php
RewriteRule ^register\.php$ http://example.com/login/? [R=301]
  • 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-06T08:30:04+00:00Added an answer on June 6, 2026 at 8:30 am

    You are causing a redirect loop. You should be redirecting when the original request is for the php file, and rewriting when the original request is for the nicer looking URI:

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /top-users(/|$|\ )
    RewriteRule ^top-users top-users.php [L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /top-users\.php
    RewriteRule ^top-users\.php$ http://example.com/top-users/ [R=301]
    
    etc...
    

    For the other 2 you need to match against query string:

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /register(/|$|\ )
    RewriteRule ^register register.php [L]
    
    # check if request for register.php does not include log=1 in query string
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /register\.php
    RewriteCond %{QUERY_STRING} !log=1
    RewriteRule ^register\.php$ http://example.com/register/ [R=301]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /login(/|$|\ )
    RewriteRule ^login register.php?log=1 [L,QSA]
    
    # check if request for register.php includes log=1 in query string
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /register\.php
    RewriteCond %{QUERY_STRING} (^|&)log=1(&|$)
    RewriteRule ^register\.php$ http://example.com/login/ [R=301]
    

    You cannot match against the query string in a Redirect or RewriteRule. You have to do it using a RewriteCond %{QUERY_STRING}

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string

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.