Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I shifted to CodeIgntier from OOP php and there are lot of links which are not working, for example this old link
http://www.flowersentiments.com/Occassional-Special/29/Birthday/122/
should actually be redirected to
http://www.flowersentiments.com/products/Occassional/29/Birthday-Gifts/122/
I have tried all methods to redirect it using .htaccess. but It just doesn't work.
Please help
In the htaccess file in your document root, you need to add your redirect rules before any of the other rules that yo uhave there for CodeIgniter:
RewriteEngine On
RewriteRule ^Occassional-Special/([0-9]+)/Birthday/([0-9]+)/$ /products/Occassional/$1/Birthday-Gifts/$2/ [L,R=301]
You'll need to do the same thing (or something similar) for all of your other broken links.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'd like to set my Apache server up so that when someone visits, say, site.com/kittens/ (or site.com/kittnes/index.php), they would actually get to view site.com/certainpage.php. Of course I could copy certainpage.php to /kittens/ and rename it index.php, but it seems like a really lame way to do it.
Any help? I feel like this shouldn't be something too complex.
You can use a rewrite rule to keep the URL the same but swap the contents out for that of another file like so:
RewriteEngine On
RewriteRule ^kittens/(index\.php)?$ /certainpage.php [L]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have searched and found solutions that were close, but I have not found anything that is exactly what I'm looking for. I have a two page/step form. I would like all external traffic pointing to page two to be redirected to page one of the form. However, traffic from page one needs to get to page two without being redirected back to page one.
Thanks!
Something like this should work for you:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://example.com [NC]
RewriteRule ^form/page2.php$ http://example..com/form/page1.php [L,R]
Going to http://example.com/form/page2.php will redirect you to http://example.com/form/page1.php unless you are linked to page2.php from within site.com.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I currently have the page '/tags.php?id=foo', and want it to display in the browser as '/tags/foo'. How might I do this with the .htaccess file?
EDIT
I've tried the solution given below and read up a little bit on Regex, but it's still not quite working how I need it to - is it possible once using the .htaccess mod_rewrite to still derive the $_GET data from the URL to use in code?
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^tags/([^/]+)/?$ /tags.php?id=$1 [L,QSA]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I was wondering what is the best way of learning how to get human readable urls on my sites.
My understanding of a human readable URL is this
www.example.com/news/articles/how-to-make-pancakes
rather than something like this
www.example.com/news.php?articleId=100001
where 100001 is the id of my articel in an SQL Database.
Any help would be much appreciated.
UPDATE:
I have tried to Google Human Readable URL's and Semantic URLs but could not find a page/tutorial that matched what I was looking for. I
Look into URL rewriting http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
For your example a simple .htaccess rule could make that change
sample URL: http://example.com/articles/10001/how-to-make-pancakes
RewriteEngine on
RewriteRule ^articles/(.*)/(.*)$ articles.php?id=$1&title=$2 [NC]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Improve this question
I have a page "page.php" on my site "www.mysite.com". "page.php" is a profile page for users on my website. Users profile can be accessed like this: "http://www.mysite.com/page.php?user=rehan". Using htaccess, I would like to rewrite the link to: "http://www.mysite.com/rehan". How can I achieve this?
Thanks in advance,
Rehan.
You can try this
RewriteEngine on
RewriteBase /
RewriteRule ^([^//]+)$ page.php?user=$1 [QSA,L]
for that you have to use :
`
RewriteEngine on
RewriteRule ^([^//]+)$ page.php?user=$1 [QSA,L]`
but on some servers you have to add :
RewriteBase /