I tried .htaccess on my local server (localhost) and it's working well.
But when upload this code to life server not working ... i don't know why ?!!
This is the content of .htaccess file
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^home/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([0-9]+)/?$ home.php?country=$1&name=$2&listingId=$3 [NC,L]
the expected that url work ... it's work on localhost only ... but on live server it's give me 404 notFound
MY-DOMAIN.COM/home/USA/David/1234
My live server is www.000webhost.com
have you tried to follow the advice given by your hoster and put RewriteBase / at the top of the .htaccess file?
see http://www.000webhost.com/faq.php?ID=16
Related
I have a URL that looks like:
DomainName/admin_panel/messages.php?order_id=7&to_id=7
I want to convert this URL to:
DomainName/admin_panel/messages
I have create a .htaccess file like below but it's not working on live server as well as on localhost. URL remains the same.. Check the .htaccess file below..
RewriteEngine On
RewriteBase /
RewriteRule ^messages/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ messages.php?order_id=$1&to_id=$2 [NC,L]
Kindly help me. The website is hosted on Dreamhost. Thanks in advance..
Hello I would like to change the url generated with php my website. I've tried with .htaccess but does absolutely nothing, I do not know if I'm doing something wrong.
Right now I do not have to test server, I can only do so locally. I have installed WAMP but including the .htaccess file in the folder www does nothing, URLs continue with php variables as usual.
I have enabled mod_rewrite in wampserver. By including text meaningless in the .htaccess file fails to access by browser to localhost, that is I think the .htaccess is working.
Htaccess I have written in this way for me to rewrite the url:
RewriteEngine on
RewriteRule ^(.*)/(.*)/(.*)$ /novedades/novedades.php?id=$1&url=$2&url=$3
#http://localhost/novedades/novedades.php?id=2&url=tren&url=tren
#http://localhost/novedades/tren/tren.php
I do not know if I'm doing something wrong, to see if I can lend a hand.
I have a very simple rewrite rule. My entire .htaccess file is as follows:
RewriteEngine On
RewriteRule ^login/([a-zA-Z0-9-/]+)$ company-page.php?company_url=$1
RewriteRule ^login/([a-zA-Z0-9-/]+)/$ company-page.php?company_url=$1
This is perfectly run on locally Wamp server but not working on online server. It display following error.!
The requested URL /EZsample/login/mereco-technologies/ was not found on this server.
Can anyone help me!
if you are using a VPS please use this article,
1.Make sure u have enabled Mod_Rewrite ?
2.Made the changes in the virtual host configurations
https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite
This line of code helped me solve a very similar issue:
Options -MultiViews
I had developed a website using Codeigniter. It was working good in localhost. When i hosted it and clicked on links i get "Internal Server Error".
Also i'm not able to see .htaccess files. Please tell me what i'm missing.
Works perfectly
Localhost:
$config['base_url'] = 'http://localhost/site/';
Welcome
When clicked above link, it goes to below url and works perfectly
http://localhost/site/welcome/page
Hosted
Public Web Server (Error):
$config['base_url'] = 'http://www.mysite.com/';
Welcome
When clicked above link, it goes to below url and gives an error
http://mysite.com/welcome/page
If you have access to the Apache error logs check those for why you are getting the 'Internal Server Error.'
On a Linux server those are usually found in '/var/log/apache2/error.log.'
On a Windows server they can by default be found in something like 'C:\Program Files\Apache\logs.' Or you can find out the location by looking in the conf file or virtual hosts conf file if you use that.
try
Welcome
see docs http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html
OR to hide index.php
add .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I think I'm missing something and don't think I really understand how rewriteBase works.
The problem I have is that I have a production site where the site is in the root directory yet I have my development site in a localhost subdirectory. Eg http://www.sitename.com/ vs http://localhost/sitename/
If I have for example an images folder I want to reference the images from the site root by using the initial slash in the href. Eg Using a relative href (without the initial slash) is not an option. This will work on the production site but the development site is looking for http://localhost/images/imagename.jpg instead of http://localhost/sitename/images/imagename.jpg
So I thought all I needed to do was setup the following in my .htaccess file to force the site root to my subdomain within the development environment:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /sitename
But this still uses localhost as the site root instead of localhost/sitename.
Can anyone please give me some pointers?
-------------------------EDIT---------------------------
I stopped trying to do this in the .htaccess file and tried to just use the html command but this also didn't work.
In the end I set up Virtual Hosts in Apache on the local server but it seems like such an awful lot of overkill to just change the site root. I'm also concerned that other developers on the LAN network won't be able to access the site properly via the virtual host.
I'm really needing some 'best practice' advice please on setting up a workable development environment in WAMP.
RewriteBase alone, basically, tells Apache where to apply the RewriteRules. Here you don't have any. By the way, you can either remove the RewriteBase directive altogether, or change it to:
RewriteBase /
The following two lines should get it to work for your development environment only:
RewriteCond %{ REQUEST_FILENAME } !-f
RewriteRule ^(.+)$ /sitename/$1 [L,QSA]
These two directives mean: "if the requested file does not exist (-f), and only in that case, rewrite the url prepending /sitename/ to the requested URI ($1)".
For more info you can have a look at Apache mod_rewrite docs and Apache URL rewriting guide.