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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:14:36+00:00 2026-05-15T06:14:36+00:00

I have been trying to write a set of htaccess rules that will do

  • 0

I have been trying to write a set of htaccess rules that will do the following:

  • With the url:
    mydomain.com/blog/something

    • If a file called blog.php exists in
      the web directory(the directory with
      index.php in) then redirect to
      blog.php?url=something

    • If blog.php does not exist, redirect
      to index.php?url=blog/something

    • EDIT: mydomain.com/blog/something is an example, it could be any url string and the htaccess should search the web directory for a file corresponding to the first part of the url string, which in this case is “blog”

In both cases I can then use $_GET[‘url’] to get parameters from the url to intiate whatever actions in my php script.

I currently have:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]*)/(.*)$ $1.php?url=$2 [L]
RewriteRule ^(.*)$ index.php?url=$1 [L]

</IfModule>

But unfortunately this is not working, I’m not sure why, I’m proficient enough with php but my htaccess skills are pretty limited. I don’t know if the [L] option is the one I should be using or if I should be using more options. Currently whatever the url string is, $_GET[‘url’] returns “index.php”.

If any more information is required just ask.

I hope someone can help
Regards
Luke

  • 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-05-15T06:14:37+00:00Added an answer on May 15, 2026 at 6:14 am

    I hope that the following directives will work for you.

    Options +FollowSymLinks +ExecCGI
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]*)/?.*$ - [E=FILE:%{DOCUMENT_ROOT}/$1.php]
    
    RewriteCond %{ENV:FILE} !^$
    RewriteCond %{ENV:FILE} -f
    RewriteRule ^([^/]*)/?(.*)$ $1.php?url=$2 [QSA,L]
    
    RewriteCond %{ENV:FILE} !^$
    RewriteCond %{ENV:FILE} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
    </IfModule>
    

    Apache mod_rewrite Reference: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

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

Sidebar

Related Questions

I have been trying to write a regex that will remove whitespace following a
I have been trying to write a script that may help me to comment
I have been trying to write and read files through P/Invoke via my ASP.NET
I have been trying to write a bare-bones ping scanner using Perl for internal
I have been trying to write an image on a layer using Quartz but
I have been trying to write my own diff3 wrap script for SVN and
I have been trying to write a custom .screenrc file TEST as follows startup_message
I have been trying to write a shortest path algorithm, dijkstras algorithm, finding the
I am new to programming. I have been trying to write a function in
Right now I have been trying to use Launchpad's API to write a small

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.