MAMP mod_rewrite returns 301 - .htaccess

I'm having trouble to set up MAMP correctly together with mod_rewrite.
My .htaccess looks like this:
RewriteEngine On
RewriteBase /api/
RewriteRule ^booking/add/?$ booking.php [NC,L]
On my Webserver everything is working fine, but running the script locally doesn't work. The response header from MAMP looks like this:
Location: http://test.local:8888/api/booking.php
Which then resolves in We are sorry, but Chrome API does not allow to get a response body for redirect.
Any idea how to fix this?
Thanks :)

Related

Wildcard RewriteRule for 301 redirects in htaccess

I'm working on setting up a 301 redirect in an .htaccess file and I can get it to sorta work, but I'm not sure why it's not picking up on anything after a specific URL in the rewrite rule.
I currently have this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/old-path/page/(.*) /new-page/ [R=301,L]
</IfModule>
Which works fine if I test it with http://example.com/old-path/page which redirects to http://example.com/new-page
But if I try this:
http://example.com/old-path/page/test it will 404 and not redirect to http://example.com/new-page
Overall, since I'm not 100% if there are any other pages from the old path that may be nested within the page I want to make sure that I'm catching any of them and just redirecting to the new-path outright.
So, I'm not sure if I'm setting this up incorrectly or if there is something that I'm missing?

Rewrite example.com/index.php/... to example.com/... using mod_rewrite and .htaccess

I am migrating my site from Wordpress to Jekyll and I would like to keep the URLs working. My idea was to use a .htaccess file for this and to place it in the root of the site. But unfortunately after trying several tutorials and generates it doesn't seem to work.
The old URLs have the following format
http://example.com/index.php/2016/05/07/title-of-the-blog-post/
The new URLs have this format:
http://example.com/2016/05/07/title-of-the-blog-post.html
Among others I've tried this example which looks good to me, but it actually casues all pages on my site to display an error message :)
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^index.php.*$ http://example.com/ [R=301,L]
I think that should take all URLs that start with example.com/index.php and make them start with example.com/, but apparently that is not the case.
To redirect
http://example.com/index.php/2016/05/07/title-of-the-blog-post/
to
http://example.com/2016/05/07/title-of-the-blog-post.html
you can use the following rule :
RewriteEngine on
RewriteRule ^index\.php/(.+)$ http://example.com/$1.html [NE,L,R]
or alternatively you can use mod_alias like that:
RedirectMatch 301 ^/index\.php/(.+)$ http://example.com/$1.html

How to do a 301 redirect for a specific page across directories

I am having trouble getting a simple 301 redirect to work in a .htaccess file. I simply need to redirect a single old url to the new page. I've tried many variations but the code seems so simple that I can't think of any ideas as to why its not working. Its an Apache server, and I don't have access to the httpd.conf file. Other .htaccess configurations I have work fine, however I removed everything but the following code:
Options +FollowSymLinks
RewriteEngine On
Redirect 301 /old-directory/old-page.php http://www.example.com/new-page.php
Is the redirect clause really on two lines?
Put everything on one line:
Redirect 301 /old-directory/old-page.php http://www.example.com/new-page.php
Redirect directive is not from mod_rewrite module. Try this in /old-directory/.htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^old-page\.php$ http://www.example.com/new-page.php [L,NC,R=301]

How to write url rewrite in codeigniter

I write the url rewrite in .htaccess in codeigniter as follows
RewriteEngine on
RewriteRule ^Vorarlberg.html$ index.php/users/suchergeb?short_query=true&sbundesland=V&offset=0&limit=25&country=A [L]
RewriteRule ^Tirol.html$ index.php/users/suchergeb?short_query=true&sbundesland=T&offset=0&limit=25&country=A [L]
myproject is located in wamp server under irat.2013 folder
the above code is working but we dont want to show full url, we would like to show
as follows
irat.2013/Vorarlberg.html
and one more thing if we give the full localhost url before the index.php/users... then only it is working other wise it is not.
Please help me ....
Use the application/config/routes.php file. Check docs here: http://ellislab.com/codeigniter/user-guide/general/routing.html

i dont know what error in my url rewrite

I am trying to rewrite my url using the htaccess file, but it does not work. I have enabled mod_rewrite and Allow Access, but still it does not work for local and online. What is wrong with my rewrite code?
I want to rewrite this url
http://example.com/post/post.php?pid=104
like this
http://example.com/post/post-pid-104.htm
This is my htaccess code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule post-pid-(.*)\.htm$ post.php?pid=$1
This should work: RewriteRule post.php?pid=(.*)$ post-pid-$1.htm$
The rewrite lines are fine, it looks like it's a problem with your server configuration.
You can test your rewrite rules with this: http://htaccess.madewithlove.be/

Resources