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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:27:10+00:00 2026-06-11T07:27:10+00:00

I am trying to rewrite all URIs inside directory /docs to /docs/index.php, using apaches

  • 0

I am trying to rewrite all URIs inside directory /docs to /docs/index.php, using apaches mod_rewrite module.

The URI doesn’t exist as a directory structure, which I don’t think is necessary when you are rewriting the URI to something that exit.

I am getting the error:

“The requested URL /docs/view/my_doc was not found on this server.”

These are my rewrite rules:

   RewriteEngine On
   RewriteCond %{REQUEST_URI} ^docs/([a-z]+)/([A-Za-z0-9_-]+)/?$
   RewriteRule ^(.*)$ http://%{HTTP_HOST}/docs/index.php?action=$1&target=$2 [QSA,L]

I am doing the configuration in httpd.conf. Also, I am using a multi v-host setup.

What’s my problem and how do I fix it?

I’m using Apache/httpd on CentOS 6.2


UPDATE

Including my VirtualHost as well:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.smicloud.org
    ServerAlias *.smicloud.org
    VirtualDocumentRoot /var/www/html/www.smicloud.org
    ExpiresActive On
    ExpiresDefault "access plus 14 days"
    # insert logging config, anything else you need..
    #Define FileEtag so it doesnt use node
    FileETag MTime Size
    <Directory /var/www/html/>
        Order Allow,Deny
        Allow from all
        # Get rid of this if you need to allow htaccess files:
        AllowOverride None
    </Directory>
        RewriteEngine On        
        RewriteRule ^docs/([a-z]+)/([A-Za-z0-9_-]+)/$ /docs/index.php?action=$1&target=$2 [QSA,L]
</VirtualHost>
  • 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-11T07:27:12+00:00Added an answer on June 11, 2026 at 7:27 am

    Ok, there were a couple of things that I had to do in order to fix it, using @donalds suggestion (which I actually tried before):

    1 – I had to have a ‘?’ at the end of the regex of RewriteRule:

    ^/docs/([a-z]+)/([A-Za-z0-9_-]+)/?$

    Then I can chose whether to have a ‘/’ or not at the end of the address.

    2 – I had to add a ‘/’ to the beginning of the regex of my RewriteRule. I.e.:

    ^/docs/([a-z]+)/([A-Za-z0-9_-]+)$

    3 – I also had to add the ‘http://%{HTTP_HOST}/’ part to the new URI:

    http://%{HTTP_HOST}/docs/index.php?action=$1&target=$2 [QSA,L]

    This is what I ended up with:

    RewriteRule ^/docs/([a-z]+)/([A-Za-z0-9_-]+)$
    http://%{HTTP_HOST}/docs/index.php?action=$1&target=$2 [QSA,L]

    Perhaps why I needed to add the %{HTTP:HOST} was because it’s a multi virtual host setup.

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

Sidebar

Related Questions

I'm trying to rewrite a url of this: http://www.foo.com/bar/baz to index.php?q=$1&d=baz Where bar is
I am trying to rewrite my URLs in PHP using the output buffer. Ideally
I am trying to rewrite URLs using mod_rewrite. It is enabled in httpd.conf and
I am trying to rewrite a url so that all requests for /admin get
I'm no expert in mod_rewrite at all and I'm trying to add a condition
I am trying to rewrite a URL using .htaccess. I am running on Apache
What I'm trying to accomplish with htaccess mod-rewrite: Redirect all sub-domains to new domain
I'm trying to rewrite URLs to a generic show_page.php script, but I'm having trouble
I'm trying to rewrite all the urls for my website. For example, if the
I have a website and am trying to rewrite all urls with 'http://www...' 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.