In my php page i have given link as href="test.php?category="xyz".
In url I want this page link to appear as "test/xyz".
In my .htaccess file i have added
RewriteRule ^test/([a-zA-Z]+) test.php?category=$
but this does'nt work for me.
All the other links in test.php gets test appended to their links.
eg. if there was example.php its appears as test/example.php
Help is appreciated.
Thanks in advance
Maybe this code can help you
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^test/([a-zA-Z]+)$ test.php?category=$1
</IfModule>
Try to access these urls : test.php?category=abc and test/abc. If two pages show the same content this code successful.
To learn more, please read the reference here
This sounds more like you forgot the use full relative paths in your links. Instead of using:
example
You should use:
example
Else when you are on page /test/abcd, going to example.php means /test/example.php
Related
This is a link on index.php page
<?= $mbbelow['brand_name']; ?><?= $mbbelow['title']; ?>
from this link I come on page specification.php
then this url come http://www.themobilesapp.com/specification.php?url=Sony-Xperia-Z5-specifications-5246.php
in the base of url I find all data of page.
This url is not proper according to me.
Here I want to remove specification.php?url= from this above url.
Please tell me in proper and full explain way that how to remove and make new url like this
http://www.themobilesapp.com/Sony-Xperia-Z5-specifications-5246.php
I only need .htaccess or I also need to work using php code to remove this.
I will provide you all details you need here for to remove this.
Please try this in .htaccess file:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ specification.php?url=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ specification.php?url=$1
I have the following file/folder structure for my site:
index.php
games.php
/category-games
/category-games/game-1.php
/category-games/game-2.php
The file games.php is supposed to be a category homepage for /category-games/. Is there any way to make this page show when someone visits mysite.com/category-games/? I tried to put the page into the folder and called it index.php but I guess that's not working.
Probably need to do this via .htaccess. Anyone can help me with this? Right now if anyone tries to access mysite.com/category-games/its going straight to 404.
Cheers!
Case 1: If /category-games/ has no .htaccess then place this rule in root .htaccess:
RewriteEngine On
RewriteRule ^category-games/$ games.php [L,NC]
Case 2: If there is a .htaccess inside /category-games/ then use this rule
RewriteEngine On
RewriteRule ^/?$ /games.php [L]
Well, if you are thinking about in a organize and systematic coding, then I would like to suggest you to use PHP Routing library. There are many ready mate routing classes available. If you want to use that, surely it will help you to make your code more organized way.
For example, if you want to access mysite.com/category-games/, behind the scene, routing will trigger your corresponding page.
Following code will try to access mysite.com/category-games folder but it will trigger out your-page.php file where user can see only mysite.com/category-games url, nothing else.
$router->any('/category-games', function(){
return 'your-page.php';
});
Isn't cool?
The list of routing library are-
https://github.com/chriso/klein.php
https://github.com/nikic/FastRoute
Hope, will help you to do your project. TQ
Try making a new page called index.html under /category-games/ with the following contents:
<meta http-equiv="refresh" content="1;url=http://yoursite.com/category-games/games.php">
That would make index.html load by default but instantly redirect to games.php. The 1 is for how long to wait before redirecting. 1 is best so it doesn't overload your browser.
Toodles!
-HewwoCraziness
My question title may not be appropriate but you i can try to explain the problem i am, running through here in the description :
What i want is that one page of the site should be redirected to a particular url and the rest to another one.
i.e.
www.mysite.com/industries/accounting.php should redirect to www.mysite.com/new-industries/accounting
where as
www.mysite.com/* should point to www.mysite.com/newsite
I hope i make sense here. issue is that whenever i try to put in a rule it gets looped for the specific page. any help is appreciated.
Regards.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^industries/accounting\.php$ /new-industries/accounting [L,NC,R=302]
RewriteRule ^((?!newsite/).*)$ /newsite/$1 [L,NC,NE,R=302]
I'm fiddeling around with a problem and cant find a solution. What is basically needed is that I have a site where download button inserts a random code in the end of the URL, example
Thank you
But currently the url will look like xx.mydomain.com/thanks.php?uq=2js98 or etc, what I would like to do, is that the url would look xx.mydomain.com/thanks2js98.php or just xx.mydomain.com/thanks2js98
I have tried all the info I can find, but I think I'm not at home with all the code :(
Step 1:
Modify your PHP code to this:
Thank you
Step 2:
Put this code your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^(thanks)[0-9]+(\.php)$ /$1$2 [L,NC]
I want a user to click on link of www.domain.com/how-it-works
My URL Rewrite is:
RewriteRule ^how-it-works/?$ index.php?action=about&link=howItWorks [NC]
index.php GETS "action" and "link" parameters, and then this is where I get lost...
I am currently using the following:
require( TEMPLATE_PATH . "/about.php" );
This loads up the about.php template file, which is exactly what I want, but then where do I put the "same page link" of: #HIW? #HIW is a link inside the about.php template file.
The #HIW in your url is called a fragment identifier in HTML.
Supposing you are using apache, you can go with (note the NE and R flags at the end):
RewriteRule ^how-it-works/?$ index.php?action=about#HIV [NC,NE,R]
(I took of &link=howItWorks because I suppose #HIV replaces it, if not you can put it back)
http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_ne
As far as I understood your URL Rewrite already carries that link information. In this case the HIW you mentioned above as the final loading url is index.php?action=about&link=howItWorks.
Why don't you $_GET['link'] inside the about.php and write the output from that result?
I mean, if you want to give the answer from the about.php file, you can get the link information with $_GET[] and give your desired result information from there.
Expand your rewrite to allow inner links:
RewriteRule ^how-it-works/?(#.*)?$ index.php?action=about&link=howItWorks [NC]
Please not I don't know if this reg ex works I just typed it out quickly. Please try a few if its not working properly.
It should 'just work' :)