url rewriting in php on xampp server - url-rewriting

I've trying out url rewriting with a php script on my xampp server. First i created a .htaccess on the same folder as the script and then wrote the following lines in it
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^direct/?$ direct_name_here.php [NC,L]
to rewrite localhost/map/direct_here123.php to localhost/map/direct/
But the browser displays the url localhost/map/direct_here123.php instead of localhost/map/direct/
How can i fix it?
regards
ED

Related

Magento 404 front end on Multi Site after moving server

We have recently moved a Magento multi site environment to a new dedicated server, however all the sites apart from the admin URL site (not used apart from admin are) are reporting Magento style 404 pages on the front end.
We have ensured mod_rewrite is turned on, checked the database and manually amended the URLs in PHPMyAdmin to assign some temporary test URLs. The URL assigned to the admin area works fine, and the rest resolve to the server, however every front end is still 404. We have tried adding in index.php to the URL, no change. Checked all file and folder permissions, all OK. Cleared all cache manually and reindexed from command line. No change.
We have checked HTACCESS is correct which it looks to be. We have even taken another backup of the database and full site and restored to another server with the same issues.
We have also tried disabling SEO urls/URL Rewrites without change too.
Error logs dont say a lot either which isnt helpful.
Really struggling with this now so any help or pointers greatly appreciated. Thanks
First Solution:
Replace current .htaccess file with the default .htaccess file from Magento.
Second Solution:
#fastcgi_param MAGE_RUN_CODE default;
If doesn't work, try following solution:
Third Solution:
Is this installed on an Apache webserver? If not, the .htaccess functions will need to be translated to your flavor of web server software.
Has DSO module for mod_rewrite been installed in Apache and been enabled to load?
Is AllowOverrides enabled for the virtual server so Options +FollowSymLinks will function? You may have to check with your hosting service provider and have it enabled.
Is Magento's .htaccess file available in the doc root folder?
Has the rewrite engine been turned on in the .htaccess file?
Has the proper RewriteBase been assigned in the .htaccess file?
General entries in Magento's .htaccess that must function so rewrites will function to eliminate the need for index.php to appear in the URL.
<IfModule mod_rewrite.c>
############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## you can put here your magento root folder
## path relative to web root
#RewriteBase /magento/
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
Third solution from Fiasco Labs

Configuring CakePHP .htaccess for Cpanel ~temp/ URL

I'm trying to set up CakePHP 2.x in Cpanel (Hostmonster) while the domain of the site is still pointing to the older server. In order to pull up the site without the domain (for demo), I have to use http://[hosting-IP-address]/~mysite.
This is my default .htaccess file located in the root (the one before app/ folder):
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
If I leave it as it is, I get 404 error. When I remove the .htaccess file or leave it blank, the site content loads, but without CSS. The site files are located in /home2/mysite/public_html/ folder. I tried adding RewriteBase with different combinations (~mysite, mysite, mysite/public_html), but no avail.
I have tried with rewrite base setting then i get 500 internal server error. Please suggest
Instead of changing your site .htaccess code. I will suggest you update your local pc host file to point your site to new server, so that you can check your all URL.
Open your hosts file which is located at : c:\Windows\System32\Drivers\etc\hosts and add the following code with your new hosting IP address
hosting-IP-address www.domain.com
hosting-IP-address domain.com

mod_rewrite issues with something that used to work

I have a virtual private server that was borked over the weekend, and has been upgraded. Sometime between now and then, some changes have been made that have impacted a mod_rewrite call, but I'm not sure which.
In any event, I have a folder with a PHP script that emulates a CAS server. The system used to work fine and dandy until today. Now, instead of the mod_rewrite directives providing commands via rewrite to the index.php file, Apache goes '404' and sends me up a directory to Wordpress's 404 handler.
This is the htaccess code that used to work:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?mode=$1 [QSA, L]
The URL variables appeared in CAS-appropriate commands (like cas/login, cas/logout), but are now generating 404s.
There may have been Apache tweaking; do I need to add any commands to the htaccess (like Options Indexes) or something to make Apache listen to the rewrite commands?
Oddly, the force-https command seems to work.

.htacces file and MAMP

I have installed MAMP on my laptop and moved my web project (developed using CodeIgniter) under MAMP's webroot.
I use an .htaccess file to hide my index.php file within my urls and everything is working fine...almost, everything.
I'm able to surf my site locally as in my remote server but some folders/files are not recognized. Looks like they are missing or the path is not matching the physical location on my laptop.
Basically I have configuration like below:
MAMP
htdocs
myFolderSite
.htaccess
site
myApplicationFolder
.htaccess
config
controllers
views
.....
...
myPublicFolder
css
images
.....
...
Surfing my site locally css and images are not visible. All the required files are present under the proper folders within myPublicFolder.
The .htaccess file I'm using in myFolderSite appears as below
RewriteEngine On
RewriteBase /myFolderSite/
RewriteCond $1 !^(index\.php|images|upload|users|thumb|fckeditor|public|css|js|robots\.txt|sitemap2\.xml)
RewriteRule . index.php [L]
Am I missing something?
Thanks in advance
The CodeIgniter wiki has a good article on Mod Rewrite that is worth looking at. Specifically, these two lines will stop actual files and directories being redirected.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
I've used this across a few different servers and Macs, without too many problems, so hopefully it helps.

Apache mod_rewrite does not work

Im using a J2ee application with spring framework 2.0 on a apache tomcat 5.5. I have used URL mapping to change the extension from .jsp to .htm. I have an URL which looks like this
http://www.800promotion.com/promotion.htm?cid=1344159422528120632840257756098788
I want to change it to
http://www.800promotion.com/1344159422528120632840257756098788
I have referred samples of working on mod_rewrite. However I cant seem to get it working. These are the lines in my .htaccess file.
RewriteEngine on
RewriteRule ^([^/.]+)/?$ /promotion.htm?cid=$1 [L]
I have checked with my host and they said mod_rewrite was supported on the server. I do not have access to the httpd.conf file. However I have verified from the support that AllowOverride is set to all. When I hit the URL the page works fine however the URL doesnt get mapped. Where am I going wrong?
RewriteEngine On
RewriteRule ^(.+)$ promotion.htm?cid=$1 [QSA,L]
Try this
You need a correct .htaccess directives. Try the following solution:
RewriteEngine on
RewriteBase /
RewriteRule (.*) promotion.htm?cid=$1 [L,I,U]

Resources