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

  • Home
  • SEARCH
  • 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 7820623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:22:14+00:00 2026-06-02T07:22:14+00:00

Okay, I’ve looked around a bit, and I cannot seem to find the answer.

  • 0

Okay, I’ve looked around a bit, and I cannot seem to find the answer.

Now I’m not asking for you to give me just a block of code, and say “this is the fix”, I would like for you to explain how you did it, what you came up with, etc. I would really like to know more about this, and the only way to learn is by example.

Now what I need to do is:

Currently my blog (word press go figure, cause they own the world), is on the root directory. So my posts look like: http://localhost/hello-world. Just an example.

However, I’ve just extended my site, with a custom built PHP script using Code Igniter. I need to put the Code Igniter script on the root directory, and move the blog to /main/ or /blog/. I don’t want to get rid of my blog, but I don’t want Google to have to re-index every single blog post there is, or have Google lead to bad post urls. More importantly I don’t want to have to sit here for hours and hours, creating redirect urls to each and every single blog post (theres hundreds of them).

Now I need the redirect to be a 301 redirect.

Heres the problem I have come across.

I NEED to have this in the .htaccess:

 RewriteEngine on
 RewriteCond $1 !^(index\.php|admin|css|img|js|main|favicon.ico)
 RewriteRule ^(.*)$ index.php/$1 [L]

This removes the ugly localhost/index.php/controller/controller-function/

But I need to make my .htaccess redirect everything on the / but NOT the preset urls I already have.

The Preset url arguements I have through Code Igniter are:

/details/
/register/
/city/
/search_process/
/login/
/logout-success/
/login-success/
/logout/
/login/
/manage/
/panel/

So in essence..

localhost/hello-world/ would have to 301 redirect to localhost/main/hello-world

and

localhost/(any-of-the-above)/ would have to NOT redirect to /main/ or /blog/

Also if you notice in the current .htaccess, I’ve allowed certain things like /admin/ /css/ /img/ /js/ (/main/ is the blog obviously) and favicon.ico (cause it looks awesome)

Please school me! (How often do you hear that? :P)

CREDIT GOES TO LAWRENCE CHERONE!

He originally gave me the answer, and between then and now I think I made a typo the first time, and lost the code by accident, and it didn’t work the second time after copy / pasting (cause the first time i actually typed it out to learn it).

So here goes with the modified working solution. I give full credit to Lawrence Cherone (the guy who has the accepted answer for this question) because he helped me figure this out, and ultimately I couldn’t have gotten this working solution without him.. Thanks again bud!

RewriteEngine on
RewriteCond $1 !(panel|manage)
RewriteRule ^(.*)$ http://localhost/choosefitness/main/$1 [R=301,L]

RewriteEngine on
RewriteCond $1 !^(index\.php|admin|css|img|js|less|favicon.ico)
RewriteRule ^(.*)$ index.php/$1 [L]

This simply states, that as long as the first argument http://localhost/choosefitness/first-argument is no /panel or /manage. It should 301 redirect to /main/ (Had to provide full URL for 301 redirect, not just main/$1)

Then it states that any request made on admin css img js lss or favicon.ico should be ignored. else should be made on index.php (this removes the index.php from the url in code igniter)

I do not know why it works i just know it does. However I havent tested it fully but I believe to be able to access /css without beign redirected, you have to add |css to the first RewriteCond. However the server is able to access the css files without needing to do so.

  • 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-02T07:22:20+00:00Added an answer on June 2, 2026 at 7:22 am

    This is untested & pretty sure index.php/$1/$2 is wrong but… You could include a rule that matches your CI rules and then pass to the CI controller, and if not match is found then rewrite to your /blog/ url. Also dont forget to escape the . in the favicon\.ico part.

    RewriteEngine on
    RewriteCond $1 !^(index\.php|admin|css|img|js|main|favicon\.ico)
    
    RewriteRule ^(details|register|city|search_process|login|logout-success|login-success|logout|login|manage|panel)/(.*)$ index.php/$1/$2 [L]
    RewriteRule ^(.*)$ /blog/$1 [L]
    

    Edit: If your parameter is at the front then switch the rule to something like this:

    RewriteRule ^(.*)/(details|register|city|search_process|login|logout-success|login-success|logout|login|manage|panel)$ index.php/$1/$2 [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so the answer to my question might not be the problem but here's
Okay, so I've done a bit of research into using PHP to allow using
Okay. Tough to find the best starting point, here. The error XCode (4.3.2) in
Okay, none of the previous questions I have seen with this error seem to
Okay so the title may be a bit misleading. What I am trying to
Okay, so I'm not even sure how to ask this question (much less search
Okay, I'll say now that I know very little about Java. I was given
Okay, not quite sure how to explain it but I'll try my best... I
Okay, I've been messing around with the excellent JodaTime library, attempting to get a
Okay, so I did search a bit before posting... no luck (or maybe I'm

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.