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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:28:23+00:00 2026-05-30T12:28:23+00:00

I am probably attempting to take URL Canonicalization a bit too far but here

  • 0

I am probably attempting to take URL Canonicalization a bit too far but here it goes anyway.

Basically I am looking to the following:

  1. 301 redirect every base url to http://www.mydomain.com/ some pages are https it should recognize that and continue to use https where already used/requested
  2. 301 redirect away any trailing slashes ie http://www.mydomain.com/page/ becomes http://www.mydomain.com/page (I already have a line of code that finds the index.php page – this site is built on Codeigniter)
    • I Don’t want the base url to have the slash stripped that is the only time a slash should be left behind
  3. Find any instances of index.php (in the front middle or end of the url) and 301 redirect them out
    • ie http://www.mydomain.com/index.php/page/index.php/ becomes http://www.mydomain.com/page
  4. 301 redirect any use of my ip address to the actual domain
    • ie 11.11.111.111/page/index.php would become http://www.mydomain.com/page

Here is what I have so far in my htaccess file in my root directory:

RewriteEngine on

Options +FollowSymLinks 
RewriteCond %{REQUEST_URI}   ^(.*)(/index\.php)$
RewriteRule ^(.*)index\.php/$  http://www.mydomain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST}   ^(mydomain\.com)(:80)? [NC]
RewriteRule ^(.*)$  http://www.mydomain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST}   ^11\.11\.111\.111$
RewriteRule ^(.*)$  http://www.mydomain.com/$1 [R=301,L]

#This makes sure that the server actually finds the index file although its not in the url
RewriteCond $1   !^(index\.php|images|assets|downloads|css|js|robots\.txt)
RewriteRule ^(.*)$  /index\.php/$1 [L]

I am stuck right now any help would be greatly appreciated!!

Revisions!!

I have made some progress and here is what I have so far

<IfModule mod_rewrite.c>
RewriteEngine on

# index.php to /
RewriteCond %{THE_REQUEST} ^GET\ /.*/index\.(php|html)\ HTTP
RewriteRule (.*)index\.(php|html)$ /$1 [r=301,L]

# index.php to / at the base url
RewriteCond %{THE_REQUEST} ^GET\ /index\.(php|html)\ HTTP
RewriteRule (.*)index\.(php|html)$ /$1 [r=301,L]

# force www.
rewritecond %{HTTP_HOST} ^paolienvelope.com [nc]
rewriterule ^(.*)$ http://www.paolienvelope.com/$1 [r=301,L]

# force no IP
RewriteCond %{HTTP_HOST} ^70.40.204.154
RewriteRule ^(.*) http://www.paolienvelope.com/$1 [r=301,L]

#codeigniter direct
RewriteCond $1 !^(index\.php|images|assets|downloads|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

This successfully forces ip to url
Removes index.php or index.html from the url but correctly directs to the index file despite
makes sure the base url has www.
Still dont have the code to remove the trailing slash from only the request
any help would be appreciated!! Thanks!

  • 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-30T12:28:25+00:00Added an answer on May 30, 2026 at 12:28 pm
    RewriteEngine on
    
    # index.php remove any index.php parts
    RewriteCond %{THE_REQUEST} /index\.(php|html)
    RewriteRule (.*)index\.(php|html)(.*)$ $1$3 [R=301,L]
    
    # force www. (also does the IP thing)
    RewriteCond %{HTTP_HOST} !^www\.paolienvelope\.com [NC]
    RewriteRule ^(.*)$ http://www.paolienvelope.com/$1 [R=301,L]
    
    # remove tailing slash
    DirectorySlash off
    RewriteCond $1 !^(index\.php|images|assets|downloads|css|js)
    RewriteRule ^(.*)/$ $1 [R=301,L]
    
    # codeigniter direct
    RewriteCond $1 !^(index\.php|images|assets|downloads|css|js|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably a long question for a simple solution, but here goes... I have a
Probably missing something completely obvious here, but here goes. I'm starting out with Spring
Probably a bit off topic question, but it's something I'm really interested in getting
I know this is probably a simple question, but I'm attempting a tweak in
This is a probably a dumb question but here is what I've got. A
The title may be a bit vague, but here's my goal: I have a
Probably not much more to elaborate on here - I'm using a NumericStepper control
Probably a noob question, but I'll go for it nevertheless. For sake of example,
Probably really easy for a pro, but could someone re-write this from it's PHP
Probably a dumb question, but is it still using Include files?

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.