Free Web Hosting Forum
(#1 (permalink))
Old
xmakina's Avatar
Senior Member
xmakina is on a distinguished road
 
Posts: 854
Join Date: Feb 2009
Location: Oxford, UK
Default Howto Mod_Rewrite with 000webhost - 12-06-2009, 11:35 PM

There have been a few posts now regarding getting .htaccess to work. Every host/server is different so your mileage may vary outside of 000webhost, but this works perfectly for me.

Code:
# Handle real errors with index.php
ErrorDocument 403 /index.php
ErrorDocument 404 /index.php
#
Order Deny,Allow
<FilesMatch "\.ht(access|passwd)$">
Deny from all
</FilesMatch>
#
# challenging but recommended way of developing
php_value allow_call_time_pass_reference 0
#
Options +FollowSymLinks
RewriteEngine on
#

#Redirect domain.com to www.domain.com
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.co\.uk
RewriteRule (.*) http://www.domain.co.uk/$1 [L]

#Use friendly URLs (or failing that output the path to $_GET['rt'])
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteCond %{REQUEST_URI} !^/robots.txt$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js|pdf|doc|xml)$
RewriteCond %{REQUEST_URI} !-f
RewriteRule (.*) /index.php?rt=$1 [L]
This .htaccess is intended to be used in conjunction with an MVC programming model, explained in this excellent Tutorial: http://www.phpro.org/tutorials/Model...oller-MVC.html

One thing to note is that this script disables $_GET from working in most circumstances (anything other than index.php). Instead, use either $_SESSION or pass values around using $_POST.

Last edited by xmakina; 12-10-2009 at 10:01 PM.
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Junior Member
darck is on a distinguished road
 
Posts: 3
Join Date: May 2011
Default 05-22-2011, 01:40 PM

Do you have any working code with mod_rewrite? I use below .htaccess file and test weather mod_rewrite works by entering http://domain.com/products. It should redirect to http://domain.com/2.html but instead i get http://domain.com/notfound.html Do you see any error in this code?

Code:
# Handle real errors with index.php
ErrorDocument 404 /notfound.html
#
Order Deny,Allow
<FilesMatch "\.ht(access|passwd)$">
Deny from all
</FilesMatch>
#
# challenging but recommended way of developing
php_value allow_call_time_pass_reference 0
#
Options +FollowSymLinks
RewriteEngine on
#

RewriteOptions MaxRedirects=10
RewriteRule ^/products* /2.html
Reply With Quote
(#3 (permalink))
Old
Junior Member
darck is on a distinguished road
 
Posts: 3
Join Date: May 2011
Default 05-23-2011, 08:38 PM

I was not suspecting that this issue is in FAQ
(http://www.000webhost.com/faq.php?ID=14)

Quote:
How to make mod_rewrite rules working?


We use virtual user directory paths, so you can get error when trying to setup search engine friendly URLs or trying to pass virtual directory names to PHP scripts. If can be fixed very easy. Edit your .htaccess file and add this line at the top of the file or before the first rewrite rule:

RewriteBase /

Note: if your script is installed on some directory, for example /forum, you have to place RewriteBase /forum line to the .htaccess file (.htaccess file must be also located in /forum directory)
but adding RewriteBase / seems not helping

Code:
RewriteBase /

# Handle real errors with index.php
ErrorDocument 404 /notfound.html
#
Order Deny,Allow
<FilesMatch "\.ht(access|passwd)$">
Deny from all
</FilesMatch>
#
# challenging but recommended way of developing
php_value allow_call_time_pass_reference 0
#
Options +FollowSymLinks
RewriteEngine on
#

RewriteOptions MaxRedirects=10
RewriteRule ^/products* /2.html

Last edited by darck; 05-23-2011 at 08:41 PM.
Reply With Quote
(#4 (permalink))
Old
mlt mlt is offline
Junior Member
mlt is on a distinguished road
 
Posts: 1
Join Date: Jun 2011
Default I'm having same problems - 06-03-2011, 10:22 PM

I'm trying to make typo3 to mimic static urls, but it doesn't work though I specified RewriteBase as / , etc.
Reply With Quote
(#5 (permalink))
Old
Junior Member
darck is on a distinguished road
 
Posts: 3
Join Date: May 2011
Default 06-04-2011, 12:14 PM

on my question to admins of server i got answer "Please check this ultimate guide on using .htaccess files for the best experience implementing the necessary functions.
http://www.askapache.com/htaccess/htaccess.html" although I don't know how can it help. If anybody made it working please let know.
Reply With Quote
(#6 (permalink))
Old
Junior Member
microsoft is on a distinguished road
 
Posts: 4
Join Date: Mar 2011
Default 06-12-2011, 04:55 AM

i use
RewriteEngine on
RewriteRule web/file/(.*)/[^.]+\.html web/?frame=file&id=$1
RewriteRule web/category/(.*)/[^.]+\.html web/?frame=category&cateid=$1

I can login with http://mydomain.com/web/category/1/name-of-file.html very good,but all images,and css,js are not loading.I don't know how to fix it
Reply With Quote
(#7 (permalink))
Old
Junior Member
fra.rand is on a distinguished road
 
Posts: 1
Join Date: Aug 2011
Default url mod_rewrite doesn't work, please healp - 08-08-2011, 09:45 AM

I have the following code:

#########
Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /profile.php?company=$1&id=$2 [L]

############

inside my htaccess.

it suppose to rewrite the URL in a more search engine friendly, this code do not rewrite

Thanks
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com