Is it possible to set clean url of pagination?
Default: example.com/?page=1
Clean: example/com/page/1
Can anyone have any idea how to do this?
Related
I am using linux/firefox and I'm having an issue where a jekyll theme does not work when using remote_theme: inside the .config.yml of a Jekyll project kept in a GitLab pages repo. If I clone the theme just-the-docs (https://pmarsceill.github.io/just-the-docs/) locally, it works fine when theme: is used in the .config.yml. However, when using an example of a remote theme as written by the same author pmarsceill/jtd-remote, and adding remote_theme: instead of theme:, I get the same issue. The theme does not take effect.
I use jtd-remote as an example which gives the same error, though, my goal is to get just-the-docs working as a remote theme.
Clone 'https://github.com/pmarsceill/jtd-remote'
Add url to _config.yml.
Add index.md to top level.
Add to GitLab repo and configure pages.
Browse to repo url on 4000, theme does not take effect.
When using just-the-docs, my .config.yml appears as follows:
# Site settings
title: My site Test
description: "Testing"
baseurl: "/"
url: "https://mysite.gitlab.io"
color_scheme: "dark"
search_enabled: false
# Build settings
remote_theme: pmarsceill/just-the-docs
#remote_theme: "pmarsceill/just-the-docs#v0.3.3"
plugins:
- jekyll-feed
- jekyll-remote-theme
- jekyll-seo-tag
- jekyll-sitemap
- jekyll-mermaid
- jekyll-spaceship
Any help much appreciated.
GitLab doesn't support remote themes for Jekyll.
I need add a rewrite rule in my plugin, and distribute it with my code. All works fine if I put the rule in the .htaccess in the WordPress root folder, but I need distribute the plugin with my rule.
I try to put a .htaccess inside the plugin folder and try to use the add_rewrite_rule function but doesn't works either.
Here the .htaccess code that works correctly in WordPress root folder but doesn't works in my plugin folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule my-plugin/pages/tp(.*)\.php$ wp-content/plugins/my-plugin/pages/request.php?pid=$1
</IfModule>
I try the follow code in my plugin but doesn't works either:
add_filter( 'query_vars', 'add_query_vars' );
function add_query_vars( $query_vars )
{
$query_vars[] = 'pid';
return $query_vars;
}
add_action( 'init', 'add_init' );
function add_init()
{
$plugin_url = 'the-path-to-my-plugin-folder';
add_rewrite_rule('my-plugin/pages/tp(.*)\.php'
, $plugin_url . 'pages/request.php?pid=$matches[1]','top');
global $wp_rewrite;
$wp_rewrite->flush_rewrite_rules(); // I know this should be called only one time, but I put it here just to keep simple the sample code
}
But I always get the error that the URL wasn't found.
What I'm doing wrong? How can I do what I need? I searched for similar questions but none solve my problem.
My plugin folder structure is:
Main folder: /wp-content/plugins/my-plugin
------ /pages (sub folder)
-------------/request.php (script that should receive the request)
NOTE: WordPress Rewrite API is not the same as Apache Rewrite module.
WP Rewrite API doesn't redirect a request to another URL, it used to
parse current URL and fill query_vars array.
The issue is in the second parameter of you add_rewrite_rule function call. It has to start from index.php? and then there should be your arguments, like pid, for example:
"index.php?pid=$matches[1]...."
So your add_init function should be like this:
add_action( 'init', 'wpse8170_add_init' );
function wpse8170_add_init()
{
add_rewrite_rule('my-plugin/pages/tp(.*)\.php', 'index.php?pid=$matches[1]', 'top');
}
Don't forget to flush rewrite rules by visiting Settings » Permalinks page.
Further reading:
The Rewrite API: The Basics
The Rewrite API: Post Types & Taxonomies
WP handles the plugins from the /wp-admin directory with a PHP script (admin.php), like this:
http://MyWP.com/wp-admin/admin.php?page=MyPlugin/module.php
Therefore, .htaccess files in the plugin directory are not parsed when the plugin is called. They have to be placed in the wp-admin directory or in the root directory, as you already found out.
Although copying the .htacces file to the root directory when the plugin is installed -and deleting it when it is removed- is possible, I don't think it is the best option. Having .htaccess files in the WP space doesn't seem like a good idea.
Your second approach looks much better: Creating rewrite rules in the main script.
Looking at your code, I think the problem are the pattern (Incoming URL string to match) and possibly the substitution URL path ($plugin_url in your question).
The $rule parameter in the add_rewrite_rule() function should capture a segment of the URL (Above) used to call the plugin's modules.
I can't suggest anything else because you don't supply enough information about the plugin and it's directory tree, except what can be guessed from the regex in the rewrite rule. But, this is a general idea of a way to achieve what you need.
In my codeigniter project, i have the following htaccess file to remove the index.php from URL
RewriteEngine on
RewriteCond $1 !^(index\.php|js|media|style|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
I am using the search form (using form helper). Since it is POST based, I have created a controller called "pre_search" to redirect it to search controller so that the POSTed data will be visible in URL and I can use it with URI helper's segment method.
So my pre_search controller
<?php
class Presearch extends CI_Controller {
//just to make form POST data visible in URL string for search
public function index() {
redirect('search/' . $this->input->post('term'));
}
}
And search controller does the real search. For the mean time I have allowed all the characters in URL for testing.
$config['permitted_uri_chars'] = '';
My problem is now when I have percentage sign (%) in URL it shows bad request. I think it is the apache's response and codeigniter have nothing to do with it.
After some research I found that somebody suggested to fix that problem by modifying htaccess like this
RewriteRule ^(.*)$ /index.php/$1 [B,L]
I have tried this method and it breaks everything.
Since % sign was not encoded, I tried to use also in my pre_search controller like this
redirect('search/' . urlencode($this->input->post('term')));
But didn't solve the problem.
So what is the best way to solve this? I know this is apache problem. I am just illustrating my codeigniter codes to clarify my intentions.
Thanks in advance
Deepak
I do the same, these are my params and I also found this link it might help you with the htaccess http://www.dracos.co.uk/code/apache-rewrite-problem/
$this->load->library('form_validation');
$this->form_validation->set_rules('s', '','trim|min_length[3]|required|xss_clean');
if ($this->form_validation->run() == FALSE):
$this->session->set_flashdata('errorMsg', form_error('s'));
redirect($this->session->userdata['redirectUrl']);
else:
redirect(base_url() . $this->lang->line('link_search') . '/' . $this->functions->convertToUrl($this->functions->secureString($this->input->post('s', TRUE))));
endif;
My config values
$config['permitted_uri_chars'] = 'a-z 0-9~%\.\:_\-ñ';
$config['uri_protocol'] = 'PATH_INFO';
I convert the POST to legible url, changing characters to the ones permitted, and then I do the redirect.
PHP 5.2.17
joomla 1.6.4
1and1 Linux shared server
php is running as cgi
Hi, I am trying to use a custom php.ini throughout my website. I know I can put a php.ini file in each folder, but that would not be feasible.
I searched online and found the following method:
1 - create your custom php.ini file and put it inside path/to/your/website/cgi-bin folder
2 - create the following php.cgi file
#!/bin/sh
exec /usr/local/bin/php5 -c path/to/your/website/cgi-bin
3 - upload php.cgi to /path/to/your/website/cgi-bin
4 - chmod +x php.cgi to make it executable
5 - include the following line inside .htaccess in my website root
Action application/x-httpd-php5 /path/to/your/website/cgi-bin/php.cgi
According to my understanding, after doing the above, php scripts on my website would start using my custom php.ini file instead of the default one.
Anyone can help? I spent a better part of the day trying to resolve this issue without success.
By the way, my account root (one level above my website root) has a .htaccess file with the following lines:
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
Thank you.
UPDATE 9/2/2011 - 19:37
tried including the following statement in .htaccess
SetEnv PHPRC /path/to/my/website/cgi-bin <- where my custom php.ini file is located.
According to this website it should have worked -> http://support.premiumreseller.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=85
But still nothing.
I will keep trying.
Any help appreciated!!!
UPDATE 2 - 9/3/2011 - 0:03 (WORKAROUND)
So, I couldn't find a solution for my problem. I decided to create a small php script to create hard links to php.ini in each directory that has a php script.
See below the code in case you are curious:
<?php
define('ROOT_DIR', $_SERVER['DOCUMENT_ROOT']);
define('FILE_PHPINI', ROOT_DIR . "/cgi-bin/php.ini");
processdir(ROOT_DIR);
function processdir($path)
{
$FlagNoPHP = true;
$localPHPINI = $path . "/php.ini";
foreach ( new DirectoryIterator($path) as $file)
{
if (!($file->isDot()))
{
if ($file->isDir())
{
processdir($path . "/" . $file);
}
else if ($FlagNoPHP && fnmatch("*.php*", $file))
{
$FlagNoPHP = false;
if (!file_exists($localPHPINI))
{
link(FILE_PHPINI, $localPHPINI);
}
}
}
}
if ($FlagNoPHP)
{
if (file_exists($localPHPINI))
{
unlink($localPHPINI);
}
}
}
?>
The above code looks inside each directory in my website and:
1 - if there is a php script and NO php.ini, creates a hard link to php.ini
2 - if there is NO php script and there is a php.ini, deletes the hard link (done in the last if of the function). I included this in order to clean up the filesystem of old php.ini files.
This worked for me.
I am still curious about an answer to my original problem.
I hope this helps someone!
Seems like you're taking the long way. Just modify .bashrc:
export PHPRC="/Volumes/Mac_Daddy/web_curr/public_html/php_osx.ini"
Result:
Configuration File (php.ini) Path: /usr/local/php5/lib
Loaded Configuration File: /Volumes/Mac_Daddy/web_curr/public_html/php_osx.ini
Scan for additional .ini files in: /usr/local/php5/php.d
Additional .ini files parsed: /usr/local/php5/php.d/10-extension_dir.ini
Or create an alias:
alias myphp="/usr/local/php5/bin/php -c /somewhere/someplace/php.ini"
or better yet man php.
Trying to run PHPUnit on my Kohana 2.3.4 install:
phpunit --colors --bootstrap=index.php ../../modules/phpunit/libraries/Tests.php
Getting an error at one of my modules:
<p><tt>modules/core/helpers/MY_url.php <strong>[118]:</strong></tt></p>
<p><code class="block">Undefined index: HTTP_HOST</code></p>
I realize this is happening since I'm going via command line so HTTP_HOST won't be set. Is there any way around this without rewriting HTTP_HOST in that module? I know I could rewrite it to be exec(hostname), but am trying to avoid rewriting every instance of HTTP_HOST in my code.
Any workaround you can think of?
Quick and dirty way to fix it would be to set the value in the bootstrap if you're in cli mode.
The "better" way would be to set it in the test's setUp method
Is this $_SERVER['HTTP_HOST']?
If so, have a look at adding an xml config file and setting it in there:
https://phpunit.de/manual/current/en/appendixes.configuration.html
We actually decided to use a different bootstrap, load in variables there, then require the Kohana index file.
Works like a charm. Thanks, Matt, for getting me started down that path.