EllisLab text mark
Advanced Search
2 of 3
2
   
Super .htaccess file
Posted: 25 August 2008 06:39 AM   [ # 21 ]   [ Rating: 0 ]
Avatar
Joined: 2008-04-06
142 posts

how can i do this?

i have site
http://www.site.com
which was always redirected to
http://www.site.com/shop

since google is not happy with redirection, i need to make it accessible through main site like this.

http://www.site.com loads http://www.site.com/shop without redirection
and,
i need to do this in another site redirect http://www.site.com/shop/... to www.site.com/...

thanks.

 Signature 

CodeFight CMS - based on CI 2.0 | Facebook | All CI CMS | twitter | CI | My Website

 
Posted: 25 August 2008 11:50 AM   [ # 22 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-16
411 posts

So are you looking for something like this?

# If the file/dir is NOT real go to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.*)$ /shop/index.php/$1 [QSA,L] 

You can redirect from the index to a file (like index.php) in the same way you can forward site.com to site.com/shop/

 Signature 

My Blog, C2D, PHP Videos, Résumé, Super .htaccess, Extra hooks, and MicroMVC

 
Posted: 25 August 2008 01:06 PM   [ # 23 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-22
56 posts

Xeoncross - I don’t think that’s what he was looking for, I think he needs two different rules.

#1 - Try this (not tested):

RewriteCond %{REQUEST_URI} !shop [NC]
RewriteRule 
^(.*)$ shop/$1 [L] 

#2 - Try this (again, not tested but *should* work):

Redirect 301 / /shop 

OR:

Redirect 301 http://www.your-site.com/shop 

Check the differences between 301 and 302 codes, it’s important to choose the right one according to your needs.

- uptime

 Signature 

- uptime

 
Posted: 25 August 2008 01:13 PM   [ # 24 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-16
411 posts
uptime - 25 August 2008 05:06 PM

Since google is not happy with redirection, i need to make it accessible…
...without redirection

I didn’t recomend a 301 or any other type of redirect because he stated that he wants the whole thing hidden from google/users eyes. In the same way we hide the “index.php/” with a default .htaccess.

I vote that you check to see if the query string includes the “shop/” part - then remove it if it does. Then either way load site.com/shop/index.php/

 Signature 

My Blog, C2D, PHP Videos, Résumé, Super .htaccess, Extra hooks, and MicroMVC

 
Posted: 25 August 2008 01:30 PM   [ # 25 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-22
56 posts

That’s what I thought at the beginning… But check the following quote:

dbashyal - 25 August 2008 10:39 AM

how can i do this?
and,
i need to do this in another site redirect http://www.site.com/shop/... to www.site.com/...

I agree that it’s not smart to show the same content in both / and /shop - I’m sure Google won’t like it…

 Signature 

- uptime

 
Posted: 05 November 2008 04:06 PM   [ # 26 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-16
411 posts

Has anyone tried the Google translate code on a production site? So far I haven’t used it except for testing purposes.

 Signature 

My Blog, C2D, PHP Videos, Résumé, Super .htaccess, Extra hooks, and MicroMVC

 
Posted: 30 January 2009 12:19 PM   [ # 27 ]   [ Rating: 0 ]
Joined: 2007-08-19
78 posts

I am trying to enable my pages to retrieve .swf files.  This looks like it would be perfect for my needs, but does not appear to have any effect.

The old .htaccess file that I was using (which did not enable swf either) was:

RewriteEngine On
RewriteBase 
/

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^sys.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $!^(index\.php|images|robots\.txt|css|swf)
RewriteRule ^(.*)$ index.php/$1 [L] 

I am an htaccess scavenger and would appreciate any insight as to what I am doing wrong.  smile

 
Posted: 04 February 2009 01:00 PM   [ # 28 ]   [ Rating: 0 ]
Avatar
Joined: 2007-04-27
173 posts

hmm good job with the htacces but what if i want to allow some folders like images,js etc. ?

 
Posted: 04 February 2009 04:27 PM   [ # 29 ]   [ Rating: 0 ]
Joined: 2009-01-23
52 posts

I don’t understand why by default the system and application directory are public (with index.html’s scattered around for security of course).

Why not do ...

html (static content and index.php)
application (everything you do)
system (everything CI)

 Signature 

BD

 
Posted: 04 February 2009 04:59 PM   [ # 30 ]   [ Rating: 0 ]
Avatar
Joined: 2008-02-13
113 posts

off course you can split folder like that wink

 Signature 

Sorry for my pour english :(

 
Posted: 05 February 2009 06:25 PM   [ # 31 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-16
411 posts

I don’t think it is good to split up a system into more than two directories (CI system and your appplication) because they both are different. You should never touch the system dir so you can just keep it setup on SVN updates. But the app directory could be moved around to any CI install without any trouble.

Anyway, with Apache setup right - I don’t know why people are so worried about having PHP files in the open - no one can get to them - we don’t even need “index.html” or “if(!defined)” checks.

 Signature 

My Blog, C2D, PHP Videos, Résumé, Super .htaccess, Extra hooks, and MicroMVC

 
Posted: 13 April 2009 06:27 PM   [ # 32 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-16
411 posts

I was just going over this file when I realized that it can be improved.

# If the file is NOT the index.php file
RewriteCond %{REQUEST_FILENAME} !index.php
# Hide all PHP files so none can be accessed by HTTP
RewriteRule (.*)\.phpindex.php?/$1

# If the file/dir is not real
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d

RewriteRule 
^(.*)$ index.php?/$1 [QSA,L] 

Shouldn’t we be able to check to see if it has a PHP extension instead of just point everything to the index.php file?

# If the file/dir is not real
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d

# Hide all PHP files so none can be accessed by HTTP
# If they are accessing a PHP file 
RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule 
^(.*)$ index.php?/$1 [QSA,L] 

Is this the right way to do it?

 Signature 

My Blog, C2D, PHP Videos, Résumé, Super .htaccess, Extra hooks, and MicroMVC

 
2 of 3
2