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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:54:18+00:00 2026-06-11T15:54:18+00:00

So, I just managed to write some RewriteCond and RewriteRule for a custom site

  • 0

So, I just managed to write some RewriteCond and RewriteRule for a custom site that I developed a while ago and as I’m a beginner in all of this, I was hopping that somebody will review my code and tell me if there’s anything to improve or if it is good as it is.

What I’m trying to achieve is to convert from /?mod=x to /x and from /?mod=x&type=y-z to /x/y-z

And here’s what I’ve done by now:

# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

RewriteCond %{REQUEST_URI} /([a-z]+)/([a-z\-]+)$ [NC]
RewriteRule ^([^/]*)/([^/]*)$ /?mod=$1&tipo=$2 [NC,L]

RewriteCond %{REQUEST_URI} /([a-z]+)/?$ [NC]
RewriteRule ^([^/]*)$ /?mod=$1 [NC,L]

So, everything ok? Or, is there room for improvement?

  • 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-11T15:54:20+00:00Added an answer on June 11, 2026 at 3:54 pm

    You can combine these lines and remove the RewriteCond:

    RewriteCond %{REQUEST_URI} /([a-z]+)/([a-z\-]+)$ [NC]
    RewriteRule ^([^/]*)/([^/]*)$ /?mod=$1&tipo=$2 [NC,L]
    
    RewriteCond %{REQUEST_URI} /([a-z]+)/?$ [NC]
    RewriteRule ^([^/]*)$ /?mod=$1 [NC,L]
    

    To:

    RewriteRule ^([a-z]+)/([a-z\-]+)$ /?mod=$1&tipo=$2 [NC,L]
    
    RewriteRule ^([a-z]+)$ /?mod=$1 [NC,L]
    

    Otherwise, this looks fine.


    I’m trying to add one last improvement (regarding htaccess), and that is that I would like it to redirect /?mod=inicio to /inicio. So I’m trying to do it with the following code, but It keeps building the url like this /inicio?mod=inicio

    This rule directly conflicts with your other rules. They will rewrite each other because the target of one rule is the regex match of the other. Also, you need a ? at the end of your target to remove the actual query string. You need to match against the actual request:

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?mod=([a-z]+)
    RewriteRule ^ /%1? [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am tyring to write some Java code that basically just plays a short
I'm trying to write a sync function that saves some data to nodes, which
I'm trying to write a script that will automatically update some attachments on a
I have just managed to write my first windows driver (havent registered it yet-
While multithreading is faster in some cases, sometimes we just want to spawn multiple
I was reading some file IO tutorials for C# and have managed to write
Just started with JQuery and I've managed to pass a parameter using POST, firebug
I just need clarification on what a managed prototype is. I think it is
I just got a site to manage, but am not too sure about the
I just started programming in Xcode and I'm trying to write an iphone application.

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.