Welcome Guest, Not a member yet? Register   Sign In
.htaccess weirdness
#1

[eluser]SitesByJoe[/eluser]
Ok, this is a little offtopic from CI, but I need smart brains to help me figure this out!

I had a website running on procedural PHP from years ago I just updated to run on CI.


The old site had .htaccess rewrite rules redirecting things.

Now that the site is on CI the rewrites aren't working.

I need to change this url:
http://www.seaislerealty.com/2010-LERS04-0047

to this url:
http://www.seaislerealty.com/index.php/r...RS04/2010/

and I've placed the following on my .htaccess file:
RewriteRule ([0-9]{4})-([0-9a-zA-Z]+)-([0-9a-zA-Z]+)$ /index.php/rentals/detail/
$3/$2/$1/ [L]

Before, the rewrite rule worked fine. Now I get a "no input file" error. Something's not right but the regex looks fine.

Any thoughts?

Thanks!
#2

[eluser]pickupman[/eluser]
You may also want to try and use routes. Leave .htaccess to the standard:
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

//application/config/routes.php
$route['([0-9]{4})-([0-9a-zA-Z]+)-([0-9a-zA-Z]+)'] = 'rentals/detail/$3/$2/$1';

Or try this
Code:
RewriteEngine On

RewriteRule ^([0-9]{4})-([0-9a-zA-Z]+)-([0-9a-zA-Z]+)$ index.php/rentals/detail/$3/$2/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#3

[eluser]SitesByJoe[/eluser]
Using routes was a good idea.

The trouble I'm having now is that rentals/detail/etc/etc/etc can't read data out of the uri segments. Try the link:

http://www.seaislerealty.com/2010-LERS04-0047

How do I get the data out of the re-written uri?
#4

[eluser]pickupman[/eluser]
Instead of $this->uri->segment(), use $this->uri->rsegment(). rsegment is for routed uris. In the user guide [url="http://ellislab.com/codeigniter/user-guide/libraries/uri.html"]uri class[/url] provides all the same methods except prepending r for routed uri's.
#5

[eluser]SitesByJoe[/eluser]
Nice one! I should have checked the user guide...




Theme © iAndrew 2016 - Forum software by © MyBB