xampp redirects - xampp

Does anyone has an example how to do a rule in .httpaccess in xampp?
I'm trying to redirect from localhost/test/company.php?name=Abc to localhost/test/company/Abc and I cant seem to find the solution. I followed some examples that I found on the web but none seems to work. I'm putting the .htacces file in the same folder where I have the company.php file. And I have the urlrewrite turned on.

Put the .htaccess file in your application root.
The .htaccess file should have something like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^company/([a-zA-Z0-9\-]+)$ /company.php?name=$1 [L,NC]
Turn on mod_rewrite and restart apache.
Then it should work.

Related

.htaccess MAMP difference to environment

I'm building my site on MAMP, after a couple of days I finally got an .htaccess file to work after my will. But now when I upload to live environment it doesn't behave the same! Is there different versions? Is it because of error in my file that MAMP handles automatic?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ 404.php [QSA,L]
Check if mod_rewrite is enabled in your live environment.

RewriteRule doesn't do anything

I am using the current set of re-write rules in my .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule lessons/(.*)$ page.php?url=$1
It works fine. Now I have some old pages which I would like to redirect to new pages. I do the following:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule lessons/(.*)$ page.php?url=$1
RewriteRule old/this_url/(.*)$ lessons/to_this_url/and_this_url
But when I go to www.mywebsite.com/old/this_url/another_path it simply doesn't do anything?
I tested the rule in a re-write test program and it worked. The rule was recognised. So not sure, what I am doing wrong on the live website?
Answering my own question. In fact I realized a bit late that what I was trying to do was redirecting the content of an old website to a new website. They live under the same domain name but don't live under the same root. One lives under / (the current one) and the old one lives under /old/. So the rules needed to be added to the .htaccess of the old website. In:
www.root.com/old/.htaccess (THIS IS CORRECT)
While I was trying to edit them in:
www.root.com/.htaccess (NO)
That solves my problem.

Codeigniter Index file issue

I have already worked in the CI. But this time when i remove the index file. I am getting 404 error. But i did everything correctly. Here is the settings i have done.
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/javascripts|files\/stylesheets|files\/swf|files\/upload)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /qrout/index.php/$1 [L]
Config File
$config['base_url'] = 'http://webscarlets.in/projects/';
$config['index_page'] = '';
I hope above settings are all correct. And i have tried added this 'qrout' folder in the base url still it's not working
Here is the website link
http://webscarlets.in/projects/qrout/welcome
Kindly guide me to solve this issue.
Thanks to all.
Try to use this condition .....ITs working for me
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
It looks like your rewrite condition is targeting js files and things like that. Those files don't need the index.php in their path. Only your Codeigniter files will.
I'd rework that conditional statement.

codeigniter removing index.php (possible problem with host)

Hi everyone I'm having some problems when removing index.php in CodeIgniter.
I created my application locally and it works fine but when I uploaded it, removing index.php doesn't seem to work.
I have a feeling this could have something to do with my host, it's not the best and I've had problems before. It's hosted on Fatcow.
So..
all my CodeIgniter files are located in a sub-dirctory called outfitr. e.g
<root>/outfitr/
I have my .htaccess file located in this folder with the following taken from the CI wiki:
EDITED
RewriteEngine On
RewriteBase /outfitr/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
changes fo my config.php look like the following. I have enabled query strings as I need them for a section of my application.
$config['base_url'] = "<host>.com/outfitr/";
$config['index_page'] = "";
...
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
Any help would be great. As I said I think it might have something to do with the host Fatcow.
I have tested mod_rewrite, following the steps on the following page and it seems to be enabled.
http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
ok so after some trial and error I finally got it working. I setup my .htaccess file as follows. Note the '?' in RewriteRule.
RewriteEngine On
RewriteBase /outfitr/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
Then in config.php I set
$config['uri_protocol'] = 'REQUEST_URI';
Think this is down to the way some hosts setup their mod_rewrite module. Dreamhost and hostgator have the same problem.
http://codeigniter.com/wiki/mod_rewrite/
If your installation is not in the server root you will need to amend the RewriteBase line from “RewriteBase /” to “RewriteBase /folder/”
The current .htaccess you have is re-routing all requests to /index.php, which as you said yourself is not there. You want them to route to /outfitr/index.php.
You can do this by changing the RewriteBase /outfitr/
If not, please give more detail.

Rewrite URLs for static content

I have problems with static files url rewriting in current .htaccess setup on apache2.
My app structure is:
/siteroot
/siteroot/app
/siteroot/lib
/siteroot/...
/siteroot/public <- all the static files (images, js, etc.) stored here
/siteroot/index.php
/siteroot/.htaccess
So, i need to rewrite url like /css/style.css to /public/css/style.css. I did that in really simple way, but when the file is not found it causing 10 internal redirects, which is bad. I need somehow to return 404 code if file not found, or just pass it to the next rule. And i dont have any access to site configuration file. Only .htaccess.
The reason why i`m asking this question is that the site was running on nginx and i need to rebuild the same configuration on apache.
Here is my .htaccess file.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.+\.(jpg|jpeg|gif|png|ico|css|js|swf)$ /public/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Test if a redirect is reasonable:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/public/$0 -f
RewriteRule ^.+\.(jpg|jpeg|gif|png|ico|css|js|swf)$ /public/$0 [L]
If the number of prefixes is limited, you could add another group to your regex:
RewriteRule ^(css|js|images|etc)/.+\.(jpg|jpeg|gif|png|ico|css|js|swf)$ /public/$0 [L]

Resources