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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:34:59+00:00 2026-05-11T03:34:59+00:00

I am relatively new to mod_rewrite, but have a site which I would like

  • 0

I am relatively new to mod_rewrite, but have a site which I would like to have ‘pretty urls.’ Similarly to SO :).

I am attempting to have things like: ‘http://www.whatever.com/search/test‘ get rewritten to ‘http://www.whatever.com/search.php?q=test‘ and have had some limited success. I believe that content negotiation is getting in my way…

For starters here’s my test .htaccess file:

RewriteEngine on RewriteBase /~user/mysite/  RewriteRule ^search$ search/ [R] RewriteRule ^search/([^/]*)/?$ search.php?q=$1 [L] 

Which unfortunately, does redirect to search.php, but does not pass my param in the q variable. However this does work:

RewriteEngine on RewriteBase /~user/mysite/  RewriteRule ^search$ search/ [R] RewriteRule ^search/([^/]*)/?$ s.php?q=$1 [L] # here i've renamed the search.php to s.php to dodge the content negotiation that is happening.. 

In fact, if I remove the rules all together, I get the same result as with the first version of the file. So my conclusion is that since apache is happily redirecting ‘foo’ to ‘foo.php’ even without any mod_rewrite rules, that it must be the content negotiation that is taking care of it. (This is further verified by the fact if I renamed my foo.php to foo.html, it still will find the file if i just go to ‘foo’).

So, the question is. How do I properly use mod_rewrite with regard to content negotiation? Can I disable it for a particular file? Is there a way to ensure that my mod_rewrite rules happen before the content negotiation happens?

If it is relevant, here is the conf file for the mod_userdir part of my apache conf (this test site is in my user’s homedir/public_html):

# Settings for user home directories  <IfDefine USERDIR> <IfModule userdir_module>  # UserDir: The name of the directory that is appended onto a user's home # directory if a ~user request is received.  Note that you must also set # the default access control for these directories, as in the example below. UserDir public_html  # Control access to UserDir directories.  The following is an example # for a site where these directories are restricted to read-only. <Directory /home/*/public_html>     AllowOverride FileInfo AuthConfig Limit Indexes     Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec     <Limit GET POST OPTIONS>         Order allow,deny         Allow from all     </Limit>     <LimitExcept GET POST OPTIONS>         Order deny,allow         Deny from all     </LimitExcept> </Directory>  # Suexec isn't really required to run cgi-scripts, but it's a really good # idea if you have multiple users serving websites... <IfDefine SUEXEC> <IfModule suexec_module> <Directory /home/*/public_html/cgi-bin>     Options ExecCGI     SetHandler cgi-script </Directory> </IfModule> </IfDefine>  </IfModule> </IfDefine> 
  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T03:35:00+00:00Added an answer on May 11, 2026 at 3:35 am

    Look for this option in your configuration.

    Options +Multiviews 

    It will look for

    /foo/test /foo/ /foo 

    and redirect them to

    /foo.[any file] 

    based upon if it exists and if it fits the content-type requested.

    Change the option to this to disable this.

    Options -Multiviews 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im relatively new to the Android world but I have a quick question. I
Relatively new to PHP here, but here's where I'm at: I have a simple
im relatively new to ROR, and would like some help with the following code.
I am relatively new to oracle and have written the merge statment below which
I have a relatively new wordpress installation on http://tallytree.com . I tried to change
Relatively new to Python.. I would like to know how to check if a
Im relatively new to PHP but have realized it is a powerfull tool. So
Relatively new to WinForms but I'm working on a small business app. Anyway, where
I'm relatively new javascript, but I am comfortable in other languages. I'm trying to
I am relatively new to Android, but I am looking to use an interactive

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.