i use xampp v3.2.1 and os is windows 10 Prof.
here i use url rewrite using .htaccess file. its working fine in core php file. here i use bootstrap 2 template. when i use url rewrite its alignment is not proper. here i check the output using view->source and compare using online code tool . both output are same(identical). but result show is different. i attached the output
here my .htaccess code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /o2b2b/
RewriteRule ^search/([a-zA-Z0-9]+)$ search.php?=$1
</IfModule>
original output
url rewrite used output
thanks i found the solution
please mention the base path using this html tag
<base href="/o2b2b/" />
Related
I want to add rewriterules that works in local environment (localhost) and on my liveserver.
Why?
I don't want to change rules when I test my project locally and upload it to the liveserver.
Adding Rules
Here an example
(ANY-URL)index.php?page=somepage
change to
(ANY-URL)/somepage
So I used a rewritemod generator and pasted this into it:
index.php?page=somepage
The rewriterule I got, looks like this: (of course my .htacces starts with RewriteEngine On)
RewriteRule ^([^/]*)$ /?page=$1 [L]
When I try to get to (http:)
//localhost/myproject/development/index.php?page=login it sends me to the root directory of my local development envirment. But the URL in the adressline doesn't change.
Testing
Of course I tried some other Rules by pasting the whole URL into the generator just to test if the rewrite thing works.
Also here the URL doesn't change to short-url but the server cant find stylesheets and javascripts anymore. I got redirected to the index.php
Possible solutions?
Maybe it has something todo with that "RewriteBase"?
Do i have to set a basepath?
My .htacces is located here:
//localhost/myproject/development/.htaccess
Later I also want to change paths that look like this:
(ANY-URL)index.php?page=somepage&second=hello&third=world&fourth=cool
Also here a I'm looking for a solution that works on both environments.
Since the htaccess is located inside a sub-directory, use RewriteBase:
RewriteEngine On
RewriteBase /myproject/development/
Once that is done, you use the base element in your php/html files. This will resolve the addresses for the scripts/stylesheets in your pages.
<base href="/myproject/development/" />
Now, the rewrites in htaccess would be:
RewriteRule ^((?!index\.php)[^/]+)/?$ index.php?page=$1 [L]
I have this project called 'site01'.
It is published as: 'www.example.com/site01'. The pages are like this 'www.example.com/site01/page/1'.
I'm able to route the url to 'www.example.com/site01/1', but can I change the url to 'www.example.com/s/1' through the routes configuration?
Initially I think that you have to use .htaccess way, because the issue is related to the outside of the CakePHP folder.
You can create a new file named .htaccess in the upper folder and write the instruction witch redirect /site01/ to /s/.
sample code for rewrite url:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^site01.*$ /s/ [R=301,L]
i have this in my htaccess
Options +MultiViews
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ dash.php?p=$1
RewriteRule ^([a-zA-Z0-9]+)/$ dash.php?p=$1
and im trying to make this url:
http://mywebdomain.com/dash.php?p=dash&mode=All
look like this:
http://mywebdomain.com/dash/All
Is there a way to do this?
and also if i had for example this:
http://mywebdomain.com/user/manage.php?p=manage&mode=Me
how could i get that to look like this:
http://mywebdomain.com/user/manage/Me
I have successfully managed to get the .php extension removed by the Options +Multiviews command but i am struggling trying to work out why it wont work for the re-write of the extended parts of the url.
Thanks for any help in advance too :)
Jonny
With MultiViews on, you do not need Rewrite to accomplish this.
since dash.php file exist in document root, Apache will pass requests to /dash/anything to dash.php, and that php script can parse the URI (found in $_SERVER["REQUEST_URI"]) to check what was the full uri called.
same goes for /user/manage.php ...
I have a couple of sites that are currently under development and I've put them under a specific subfolder for clients/co-workers to view - "http://dev.staffanestberg.com/site-name/". I've run into some problems getting the sites working with .htaccess. I can reach the index page by typing in the url for a site folder but neither img/style/js/etc linking or page rewriting works. Looking for a solution to this, Apache's "RewriteBase" seems to be the most likely one, however I can't get it to work.
Tried
RewriteBase http://dev.staffanestberg.com/site-name/
RewriteBase /site-name
What would be the correct method?
Thanks in advance,
-Staffan
mod_rewrite’s RewriteBase directive does only apply to rewrites using RewriteRule. And that does only apply for requests that are sent to the server.
But if the requested URIs are already wrong, RewriteBase doesn’t do any help. What you could try instead is the HTML element BASE that set’s the base URI for the current document.
I just moved my website (asp.net) to the live environment. I realized they are running IIS 6 so all my nice and clean url rewriting doesn't work anymore. I was trying to implement URL rewriting using the .htaccess file.
I want to rewrite:
www.amicobio.co.uk/Menu.aspx to www.amicobio.co.uk/Food-Menu
So in .htaccess I set:
CaseInsensitive On
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^Food-Menu$ Menu.aspx
But it doesn't work it says:
The requested URL
/a/m/amicobio.co.uk/public/Menu.aspx
was not found on this server.
Obviously the path is wrong but what is /a/m/ and how do I fix it? All the files in amicobio.co.uk/public/
Thanks.
I found the solution
it was
RewriteRule ^Food-Menu /Menu.aspx
in stead of
RewriteRule ^Food-Menu$ Menu.aspx