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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:38:24+00:00 2026-06-13T20:38:24+00:00

I have successfully created my mod_rewrite rule to change all dynamic URLs on the

  • 0

I have successfully created my mod_rewrite rule to change all dynamic URLs on the top level of the site, but now i need to create a rule for a second level, and i think later down the line i might need a second, second level of rewrites.

At the moment i have this

    RewriteEngine on 
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule ^(.+)$ index.php?subj=$1

And this helps to change /index.php?subj=home to /home as iut does for all other pages such as /contact /about /events and so on.

But now I have created sub pages under events and therefore need to change /events.php?event=event-name to /event-name. But when i add another rule it messes up the whole site. What i tried to do is this

    RewriteEngine on 
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule ^(.+)$ index.php?subj=$1
    RewriteRule ^(.+)$ event.php?event=$1

But that didnt work.

But on top of all that i want to redirect index.php and / (the root) to /home

Could anyone please show me the correct rules as I have searched around but I just can’t seem to get it right.

Many thanks in advance 🙂

Cheers

UPDATE:
Thanks for all your help so far, ive tried everything but can’t seem to get it right. As suggested by Ben I will give a bit more info on the URLs.
Right now the entire site is sitting in a sub-directory as for now its still under development, so for now it is in mydomain.com/newwebsite/event.phpevent=2
But the .htaccess file currently in the root folder of the development site so it is in /newwebsite directory.
So the URL that i am trying to write would be mydomain.com/newwebsite/event/2

You notice it says ‘2’ and that is simply the page/event id. further down the line it will not be the id but rather its title.

  • 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-13T20:38:26+00:00Added an answer on June 13, 2026 at 8:38 pm

    You are testing for the same condition twice, you need to differentiate the regex to test for a unique feature.

    I would rewrite the file similar to this:

    # Turn on the rewrite engine
    RewriteEngine On
    
    # Ignore existing files and directories
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    
    # Set the general first level rewrites
    RewriteRule ^home/?$ index.php?subj=home [NC]
    RewriteRule ^event/(.+)$ event.php?event=$1 [NC]
    

    Or alternatively you could work it hierarchically like the following. This will use the first match:

    # Turn on the rewrite engine
    RewriteEngine On
    
    # Ignore existing files and directories
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    
    # Set all the rewrites
    RewriteRule ^event/(.+)$ event.php?event=$1 [L]
    RewriteRule ^(.+)$ index.php?subj=$1 [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully created clean url for my project.. now what i need to
i have successfully created distribution profiles and installed on my xcode organiser, but this
I have created many TestProjects with Visual-Studio-2010 Ultimate . All tests were executed successfully
I have successfully created video from uiimages using AVAssetWriter. But as soon as the
I have successfully created an email that sends on creation of a Kase, but
I have successfully created rewrite rules to handle URLs like http://example.com/xyz http://example.com/xyz/ http://example.com/xyz/abc http://example.com/xyz/abc/
I have successfully created and bound computed properties, but how can I get at
HI All, I have successfully created a Quartz.NET remote server running inside a windows
I have successfully created a disabled user in Active Directory via JNDI, but I
I have successfully created DragDrop functionality with user controls. Now I am trying to

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.