I am using X-debug for memory profiling of my Drupal project and I am getting the logs and able to read them using Kcachegrind. I am getting different cachegrind files whenever I add ?XDEBUG_PROFILE=on at the end of the url. So it is pretty helpful to identify the memory usages.
But now I have to give ?XDEBUG_PROFILE=on manually to the end of desired URLs. Is there any way to add ?XDEBUG_PROFILE=on at the end of each URL with help of .htaccess or some other way?
So if my url is http://localhsot/mysite/home, then the new one will be http://localhsot/mysite/home?XDEBUG_PROFILE=on and if the url is http://localhsot/mysite/settings then the new URL will be http://localhsot/mysite/settings?XDEBUG_PROFILE=on
Please help on this.
I Hope this will help you.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(?!XDEBUG_PROFILE)
RewriteRule (.*) /mysite/$1?XDEBUG_PROFILE=on [L,R,QSA]
Add the above lines in your Drupal .htaccess
Related
I would like to ignore all query-strings in my redirect. How would I achieve this?
Basically, /project/(.*) should always redirect to /?tag=project&id=$1
/project/100?shareid=fromsomeemailprovider
should end et the ? and only redirect to Id 100.
Thank You!
I tried the following:
^/project/([^/]*)[/]?(.*)$
/?tag=project&id=$1&$2
to put the query-string behind another &, but this only works if the first URL hast a / at the end of it, which it often hasn't and the RewriteRule can't detect the ? sadly.
With your shown samples, please try following htaccess rules file.
RewriteEngine ON
RewriteRule ^(project)/(.*)/?$ index.php?tag=$1&id=$2 [QSA,NC,L]
Please make sure:
You clear your browser cache before testing your URLs.
You make sure to keep your index.php file along with your htaccess rules file. Also add / in case both of these files are in root location in your system.
until now I have always used htaccess to rewrite URLS in order to have non-SEF url to SEF urls.
Today I am facing a new challenge that honestly, beeing non confident in regular expression, I really don't know how to achieve.
I have a situation where a forum on a website of mine has been update in the following form:
previous link: www.domain.com/forum3/topic/name-of-topic/post/7548
new link: forum.domain.com/Topic-name-of-topic/
How do I intercept /post/37764 string and tell htaccess to not consider it?
And how to instruct the server to build that kind of url instead of the provious. I am very confused about it.
Any suggestion? Thank you very much. Is there any resource that I can read to help me better understand the case?
Thanks again.
EDIT
Florian answer is correct. I just added few mods to fit it better.
RewriteEngine On
#RewriteBase /
RewriteRule ^forum3/topic/([^/]+)/post/[0-9]+$ http://forum.domanin.com/Topic-$1/ [L,R=301]
RewriteRule ^forum3/topic/([^/]+)-[0-9]+$ http://forum.domanin.com/Topic-$1/ [L,R=301]
You can try this code :
RewriteEngine On
RewriteBase /
RewriteRule ^forum3/topic/([^/]+)/post/[0-9]+$ /Topic-$1/ [L,R=301]
/([^/]+)/ means that we want to catch a string containing one or more characters except / preceded and followed by a /.
This link might help you to test your .htaccess files :
Test your apache htaccess files online
I change my URL name using mod write. But my URL doesn't show the changes on browser.
This is how it looks from before and after
www.mydomain.com/toy/image.php
to this
www.mydomain.com/toy/xbox
How can I make this: www.mydomain.com/toy/xbox appear on the browser
Another words on my website it should appear www.mydomain.com/toy/xbox instead of this
www.mydomain.com/toy/image.php
This is my code:
RewriteEngine On
RewriteRule ^toy/xbox$ /toy/image.php* [L,R]
Can someone to explain to me how it works. Did I missed a step? Do I need to used PHP?
If I did make a mistake, correct me so I can learn from my mistakes. I try to google this but I couldn't find what I need to do
Any links or explanations would be appreciated. Thanks.
For it to "show the URL," you need it to do a 301/302 redirect, with a location header. All you have to do is end your RewriteRule line with [L,R=301]
You must perform a redirect using the R flag instead of just a rewrite.
RewriteRule ... ... [R]
I want to change my url with only the parameter. As I am passing only one parameter, so I want the sub url should be changed with my parameter name. I want change the url as the following type-
From:
http://www.xyz.com/cat.php?slag=season
to
http://www.xyz.com/season
Can anyone help me to do it. I don't know how to do it. Thanks
Options +FollowSymLinks
RewriteEngine On
RewriteBase /path/to/your/directory
RewriteRule ^(.*)cat/(.*)$ cat\.php?slag=$2&%{QUERY_STRING} [L]
put the above in your .htaccess file.. and that would do the magic..
Note :
RewriteBase /path/to/your/directory
(use this line only if your application is in any of subfolder the folder)
I suggest you obtain a copy of the .htaccess that WordPress uses. It's a quite powerful starting point that allows you to handle routing internally from within your Application - which you might feel more comfortable with, as it seems to me.
I have check google webmaster tools and see lot of URLs that has been crawled, they look like:
mydomain.com/somefile.php/index.php
or
mydomain.com/somefile.php/somefilesss.php?aaa=bbb&ddd=ddd
or
mydomain.com/somefile.php/someffiiii.php?iii=uuu/somefilesss.php?aaa=bbb&ddd=ddd
This is really strange.
Look like someone add the slash to URL when enter address bar, then google following them.
Currently I get fix by remove slash at the end of URLs by this .htaccess:
If it come like .php/, it will become .php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301]
But the issue is other URL still remain in google index.
I need solution to redirect the URLs which have trailing slash after php then have other file path to come back to original.
I need help to redirect eg:
mydomain.com/somefile.php/somefilesss.php?aaa=bbb&ddd=ddd
to
mydomain.com/somefile.php
Thanks for any advices.
There are 2 possible explanations to this:
Fantastic: somethere in the web, this links exist and google follows them;
Realistic: there is a bug somethere in your php engine, which produces such links and google follows them.
So IMHO you should not care about creating a rewrite rule, but check php engine for this bug.
As time passes google will "forget" previously collected urls.