htaccess redirest - .htaccess

my pages on may site working perfectly until someone puts in the browser smothing like
service.php/service.php . the page does not show any error , just an empty page. I would ht-access to redirect the user to service.php.
thanks for the help
jeff

Adding the following to your .htaccess should work if you can use mod_rewrite.
RewriteEngine On
RewriteBase /base/path
RewriteRule ^.*$ service.php

Related

force index.php in url with htaccess

I've spent the last two hours reading stackoverflow and the apache manual trying to find a solution to this, but haven't found any, if a directory is access (http://domain.ext) I'd like to force index.php to appear in the url (http://domain.ext/index.php) if possible.
If anyone could help I'd really appreciate it, thank you.
RewriteEngine on
RewriteRule index.php
you can use this:
RewriteEngine on
RewriteRule ^$ /index.php?
(but you will not see it in a browser because the rewrite engine just directs to the correct file/directory without changing the url from the browser)
with [R] tag you can redirect the user so the new url would appear in the browser
I've just found what works for me
RewriteEngine On
RewriteRule ^/?$ $1/folder/index.php$2 [R=301,L]

Mod_Rewrite with .htaccess is not working

I just learnt about url-rewrite for my website with .htacess. My actual url is:
localhost/index.php?view=some-page
So i write this RewriteRule like this:
RewriteRule ^/([^/]*)/?$ /index.php?view=$1 [NC,L]
When i typed localhost/homepage on my browser, It does not work, it displays error 404 object not found. What have i done wrong please show me.
Many thanks
This should work in your DocumentRoot/.htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/?$ index.php?view=$1 [QSA,L]
Leading slash is not matched in htaccess.
are you using apache?
This link from step 6 helped me
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04
When i was playing around with rewrites i had to enable it and tell apache where the pages were stored

.htaccess redirects : posting the subsequent uri

I have a website set up where I store all my user profiles in /member-centre/member-directory/USERNAME
My problem is that a number of referrals are posting to a depreciated structure of /members/USERNAME
Is there a way I can configure my .htaccess file to automatically post the requested USERNAME to the correct location? All i've found on google is static redirection.
If this is not possible through .htaccess, is there another method I could use?
Many thanks in advance
If you are looking for a redirect solution, Jon Lin's will work fine. If you want to do a rewrite then put the following in your .htaccess file in the root of your domain
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/members/([^/]+)$ [NC]
RewriteRule . member-centre/member-directory/%1 [L]
if member/centre etc is relative to the root filesystem and not your domain then replace the last line with (just leading slash)
RewriteRule . /member-centre/member-directory/%1 [L]
Do you mean something like:
RedirectMatch 301 ^/members/([^/]+)/? /member-centre/member-directory/$1
This redirects the browser with a permanent redirect.
Try something like this:
RewriteRule ^members/ /member-centre/member-directory/ [L]

How to redirect a webpage with .htaccess

I have this code in my htaccess but it is not working.
RewriteEngine on RewriteBase /
RewriteRule viewtopic\.php?t=([^/]+)$
http://newdomain.com/viewtopic.php?t=$1
How to redirect the page of viewtopic.php?t=1 to viewtopic.php?t=2000 to my new domain?
In addition to Daniel Gehriger's solution, add [L,R=301] at the end of the line. This will make Apache send the 301 Page Moved code to your client, informing it that the page has indeed moved permanently. This will cause search engines, RSS readers etc update their links (if they are clever enough).
You need to escape the . and ? in the pattern.
RewriteEngine on
RewriteBase /
RewriteRule viewtopic\.php\?t=([^/]+)$ http://newdomain.com/viewtopic.php?t=$1 [L,R=permanent]
just incase someone here have problem as mine, i use this code to redirect an html page to a sub domain:
RewriteEngine on
RewriteBase /
RewriteRule sharecrypt.html http://cryptool.sharepirate.com [L,R=301]

magento mod rewrite not working help wanted(htaccess) :)

my situation.....
i have this url http://www.example.com/index.php/category?catid=3
i want to have this rewritten to
http://www.example.com/bikes/3
my rewrites on the website are enabled....so i have nice urls on the website for the products
the pages i want to be rewritten are my own modules for pages with text
i have put this in my htaccess
RewriteRule .* index.php [L]
RewriteRule ^bikes/(\.*)/$ category?catid=$1
i have tried about any thing like 1000 combinations but nothing seem to work also i checked if my htaccess is working but it does.First line works also redirect to google works.
Hope someone is able to tell me what i am doing wrong here?
I had this example around here, and I think you can work it out to your needs:
Pretty URL: /topic-41/favourite-cheese.html
Ugly URL: /viewtopic.php?t=41
.htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^topic-([0-9]+)/[A-Z0-9_-]+.html$ /viewtopic.php?t=$1 [NC,L]

Resources